Aragorn
Aragorn

Reputation: 487

Disable log messages in Java zookeeper api

I am getting these log messages repeatedly..

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

I changed my log4j2.xml with root level = "OFF" as well.

How do I turn this logging off ?

Upvotes: 1

Views: 7338

Answers (3)

johnykov
johnykov

Reputation: 182

I have run the Barrier example from Zookeeper basic tutorial website and stumbled upon the same problem. Adding ZOO_LOG4J_PROP=WARN,ROLLINGFILE made the DEBUG log lines go away

Upvotes: 0

Neo
Neo

Reputation: 4880

You could add another logger in your log4j2.xml to change the log level for zookeeper. Assuming you have already defined Appender named file, you can add the Logger section as shown below

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

Upvotes: 1

eribeiro
eribeiro

Reputation: 592

Your log level is DEBUG, that indeed is quite verbose and not meant to be used in production systems. I would increase the log level to WARN or even ERROR in the log4j.properties file (conf director). See here for a more complete explanation:

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

Upvotes: 0

Related Questions