how to turn off zookeeper log info?

三世轮回 提交于 2019-12-11 01:39:25

问题


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 environment:host.name=myhost

2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@log_env@723: Client environment:os.name=Linux

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 environment:user.name=myname

...

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?


回答1:


FILE* outfile =  fopen ("nul", "w");
  zoo_set_log_stream(outfile);



回答2:


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.



来源:https://stackoverflow.com/questions/29288031/how-to-turn-off-zookeeper-log-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!