在Java zookeeper api中禁用日志消息

时间:2015-08-28 21:04:16

标签: 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

我用root level =" OFF"更改了我的log4j2.xml。同样。

如何关闭此注销?

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

您的日志级别是DEBUG,确实非常详细,并不打算在生产系统中使用。我会在log4j.properties文件(conf director)中将日志级别增加到WARN甚至ERROR。请参阅此处以获得更完整的解释:

Why does zookeeper not use my log4j.properties file log directory