在本地更改zookeeper C客户端的日志级别

时间:2016-02-04 21:42:19

标签: logging apache-spark apache-zookeeper mesos

我正在使用Apache Spark的spark-shell与mesos和zookeeper,这似乎运作良好,除了我从动物园管理员那里获得的记录比我想要的更多,这有点让人分心:

Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 1.5.0
      /_/

Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60)
Type in expressions to have them evaluated.
Type :help for more information.
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
2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@zookeeper_init@786: Initiating client connection, host=localhost:9999 sessionTimeout=10000 watcher=0xffffffffff sessionId=0 sessionPasswd=<null> context=0x777777777777 flags=0
2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@check_events@1703: initiated connection to server [127.0.0.1:9999]
2015-03-26 20:08:22,115:15978(0x7f83a1fbc740):ZOO_INFO@check_events@1750: session establishment complete on server [127.0.0.1:9999], sessionId=0x11111111111111, negotiated timeout=10000
Spark context available as sc.
SQL context available as sqlContext.

scala>

我尝试过更改$SPARK_CONF_DIR/log4j.properties

log4j.logger.org.apache.zookeeper=WARN

哪个不起作用,但我对mesos documentation mentions that the zookeeper logging goes directly to stderr

以来并不感到惊讶
  

注意:第三方日志消息(例如ZooKeeper)仅写入stderr!

将一个jar添加到spark的类路径中,该类路径具有带有外部函数接口的静态块调用zookeeper C api function to change the log level似乎可能有效,但我不确定,我没有任何经验从JVM调用C代码。

2 个答案:

答案 0 :(得分:1)

除此之外,

log4j.logger.org.apache.zookeeper=WARN

将stderr日志级别配置为仅打印优先级为ERROR(及以上)的日志。

# Send WARN or higher to stderr
log4j.appender.stderr = org.apache.log4j.ConsoleAppender
log4j.appender.stderr.Threshold = ERROR
log4j.appender.stderr.Target = System.err

LevelRangeFilter所示,here也可能有用。

答案 1 :(得分:1)

无法在此找到任何内容,但对于JNI(Java-to-C)可以提供this。看起来动物园管理员不是mesos都没有web服务或者shell(虽然在我们的例子中,但是在我们的情况下不能使用,但是在这种情况下,它不能使用)。