禁用Java zookeeper api中的日志消息
我反复收到这些日志消息禁用Java zookeeper api中的日志消息,java,apache-zookeeper,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 or
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
如何关闭此日志记录?您的日志级别是DEBUG,这确实非常冗长,不适合在生产系统中使用。我会提高日志级别,以警告log4j.properties文件(confdirector)中的错误。有关更完整的说明,请参见此处:
您可以在
log4j2.xml
中添加另一个记录器来更改zookeeper的日志级别。假设您已经定义了名为file
的Appender,您可以添加记录器
部分,如下所示
<Appenders>
<RollingFile name="file" ...
...
</RollingFile>
</Appenders>
<Loggers>
...
<Logger name="org.apache.zookeeper" level="warn" additivity="false">
<AppenderRef ref="file"/>
</Logger>
...
</Loggers>