【问题标题】:Disable log messages in Java zookeeper api在 Java zookeeper api 中禁用日志消息
【发布时间】:2015-11-23 15:05:23
【问题描述】:

我反复收到这些日志消息..

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

我也将 log4j2.xml 更改为 root level = "OFF"。

如何关闭此日志记录功能?

【问题讨论】:

    标签: java apache-zookeeper


    【解决方案1】:

    您可以在 log4j2.xml 中添加另一个记录器来更改 zookeeper 的日志级别。假设您已经定义了名为 file 的 Appender,您可以添加 Logger 部分,如下所示

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

    【讨论】:

      【解决方案2】:

      您的日志级别是 DEBUG,确实非常冗长,不适合在生产系统中使用。我会在 log4j.properties 文件(conf 导向器)中将日志级别增加到 WARN 甚至 ERROR。有关更完整的说明,请参见此处:

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

      【讨论】:

        猜你喜欢
        • 2014-01-24
        • 1970-01-01
        • 1970-01-01
        • 2015-05-21
        • 1970-01-01
        • 2012-06-17
        • 2015-07-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多