java - 在 Java Zookeeper api 中禁用日志消息

标签 java apache-zookeeper

我反复收到这些日志消息..

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

我也将 log4j2.xml 更改为 root level =“OFF”。

如何关闭此日志记录?

最佳答案

您可以在 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>

关于java - 在 Java Zookeeper api 中禁用日志消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32279748/

相关文章:

java - Dozer 在 getClassMap 上抛出 NullPointerException

java - 链表 toString()

apache-zookeeper - Zookeeper 整体数据大小限制

docker - 如何使用 docker-compose 运行 SolrCloud

apache-kafka - zookeeper.connection.timeout.ms 的最大值

java - 如何在 Spring MVC 中检索 ErrorField 的错误消息

java - 什么会让我的 html 解析代码更有效?

apache-zookeeper - Zookeeper Node 策略接龙头?

apache-zookeeper - Curator 何时以及为何抛出 ConnectionLossException?

java - 如何跨方法重用 protected JMenuItem 变量?