如何关闭 com.mongodb.internal.diagnostics.logging.SLF4JLogger?

问题描述 投票:0回答:1

使用 Spring Boot 运行,我得到这样的日志

c.m.i.d.l.SLF4JLogger : Command "insert" started on database "test" using a connection with driver-generated ID 3 and server-generated ID 13 to localhost:32795. The request ID is 13 and the operation ID is 11. Command: {"insert": "jobExecution", "ordered": true, "txnNumber": 1, "$db": "test", "$clusterTime": {"clusterTime": {"$timestamp": ...}

其中

c.m.i.d.l.SLF4JLogger
指的是
com.mongodb.internal.diagnostics.logging.SLF4JLogger

我想禁用此日志记录,但如果我更改 log4j2.xml 以添加:

    <Logger level="INFO" name="com.mongodb.internal.diagnostics.logging"/>

它仍然显示,如果我通过 application-test.yml (用于集成测试)设置日志级别,则同样适用,如下所示:

debug: false
logging:
  level:
    com.mongodb.internal.diagnostics.logging: INFO # Doesn't work
    org.springframework.data.mongodb.core: INFO    # Works

java mongodb log4j2 slf4j
1个回答
0
投票

事实证明,记录的记录器名称与用于启用或禁用它的名称不同,其中发生了一些魔法。

debug: false
logging:
  level:
    org.mongodb: INFO # Works (what...!)

© www.soinside.com 2019 - 2024. All rights reserved.