有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

禁用Java zookeeper api中的日志消息

我反复收到这些日志消息

12:31:39.085 [localhost-startStop-1-SendThread(localhost:2182)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x14f7213a94000bc after 0ms

12:31:39.142 [localhost-startStop-1-SendThread(localhost:2182)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x14f7213a94000be after 0ms

12:31:39.142 [localhost-startStop-1-SendThread(localhost:2182)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x14f7213a94000bd after 0ms

12:31:39.183 [localhost-startStop-1-SendThread(localhost:2182)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x14f7213a94000bf after 0ms

12:31:39.183 [localhost-startStop-1-SendThread(localhost:2182)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x14f7213a94000c0 after 0ms

12:31:39.256 [localhost-startStop-1-SendThread(localhost:2182)] DEBUG org.apache.zookeeper.ClientCnxn - Got ping response for sessionid: 0x14f7213a94000c1 after 0ms

我更改了日志4J2。也使用root level=“OFF”的xml

如何关闭此日志记录


共 (2) 个答案

  1. # 2 楼答案

    您可以在log4j2.xml中添加另一个记录器来更改zookeeper的日志级别。假设已经定义了名为file的Appender,可以添加Logger部分,如下所示

    <Appenders>
      <RollingFile name="file" ...
       ...
      </RollingFile>
    </Appenders>
    <Loggers>
      ...
      <Logger name="org.apache.zookeeper" level="warn" additivity="false">
        <AppenderRef ref="file"/>
      </Logger>
      ...
    </Loggers>