BAE BAE - 1 year ago 109
C Question

how to turn off zookeeper log info?

I am using zookeeper c client library. When I run my program, it will output ZOO_INFO to console. Part of log messages looks like:

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@712: Client environment:zookeeper.version=zookeeper C client 3.4.6

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@716: Client

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@723: Client

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@724: Client environment:os.arch=3.2.0-34-generic

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@725: Client environment:os.version=#53-Ubuntu SMP Thu Nov 15 10:48:16 UTC 2012

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@733: Client


I can use zoo_set_log_stream(m_zklog); to output these messages to some log files. But I prefer to turn off all the log messages. I also tried zoo_set_debug_level( ZOO_LOG_LEVEL_ERROR );. But it can not turn off all the messages.
Any ideas?

Answer Source

Use C API zoo_set_debug_level() (e.g. zoo_set_debug_level((ZooLogLevel)0)). But call this function before zookeeper_init(), otherwise, it will fail.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download