禁用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
如何关闭此日志记录
# 1 楼答案
您的日志级别是DEBUG,这确实非常冗长,不适合在生产系统中使用。我会增加日志级别,以警告日志4j中的错误。属性文件(conf director)。有关更完整的解释,请参见此处:
Why does zookeeper not use my log4j.properties file log directory
# 2 楼答案
您可以在
log4j2.xml
中添加另一个记录器来更改zookeeper的日志级别。假设已经定义了名为file
的Appender,可以添加Logger
部分,如下所示