How can I suppress INFO logs in an HBase client application?

前端 未结 3 652
谎友^
谎友^ 2020-12-30 08:01

I\'m writing a Java console application that accesses HBase, and I can\'t figure out how to get rid of all the annoying INFO messages:

13/05/24 11:01:12 INFO         


        
相关标签:
3条回答
  • 2020-12-30 08:05

    Another thing to do is change the $HBASE_HOME/conf/log4j.properties file in order to disable the logs. Personally I believe this is the best approach cause it change log level on both server and client.

    How to do that?

    1. From the server, where hbase is installed, go to the $HBASE_HOME/conf
    2. open the log4j.properties file
    3. change the configuration as you need

    If you don't know too much about log4j config file you can learn that, or just insert the following line

    • log4j.threshold=WARN

    Such configuration will only print WARNING message, you can use whatever level you want.

    Hope this can help.

    0 讨论(0)
  • 2020-12-30 08:05
    log4j.logger.org.apache.zookeeper=WARN
    log4j.logger.org.apache.hadoop.hbase.zookeeper=WARN
    log4j.logger.org.apache.hadoop.hbase.client=WARN
    

    in log4j.properties

    0 讨论(0)
  • 2020-12-30 08:31

    You may get rid of logging the packages one by one, e.g:

    Logger.getLogger("org.apache.zookeeper").setLevel(Level.WARN);
    Logger.getLogger("org.apache.hadoop.hbase.zookeeper").setLevel(Level.WARN);
    Logger.getLogger("org.apache.hadoop.hbase.client").setLevel(Level.WARN);
    

    Or just simply manipulate the rootlogger:

    Logger.getRootLogger().setLevel(Level.WARN);
    

    Note: tested on HBase 0.94.5

    0 讨论(0)
提交回复
热议问题