Skip to content

Commit bea17fb

Browse files
committed
fix: Slf4jLoggingConsumer use itself as Logger, not the server's
1 parent 3650446 commit bea17fb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mcp/src/main/java/io/modelcontextprotocol/client/Slf4jLoggingConsumer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ public class Slf4jLoggingConsumer implements Consumer<McpSchema.LoggingMessageNo
3131
// https://github.com/google/adk-java/pull/370. It's now been moved here to be useful
3232
// to others.
3333

34+
private static final Logger LOG = LoggerFactory.getLogger(Slf4jLoggingConsumer.class);
35+
3436
@Override
3537
public void accept(LoggingMessageNotification notif) {
36-
Logger log = LoggerFactory.getLogger(notif.logger());
3738
if (notif.meta().isEmpty()) {
3839
// If no meta, then just log the data as a message
39-
log.atLevel(convert(notif.level())).log(notif.data());
40+
LOG.atLevel(convert(notif.level())).log(notif.data());
4041
}
4142
else {
4243
// If there is meta, then log it as a structured log message
43-
var builder = log.atLevel(convert(notif.level())).setMessage(notif.data());
44+
var builder = LOG.atLevel(convert(notif.level())).setMessage(notif.data());
4445
notif.meta().forEach((key, value) -> builder.addKeyValue(key, value));
4546
builder.log();
4647
}

0 commit comments

Comments
 (0)