Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

hbase

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 zookeeper.ZooKeeper: Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
13/05/24 11:01:12 INFO zookeeper.ZooKeeper: Client environment:host.name=10.1.0.110
13/05/24 11:01:12 INFO zookeeper.ZooKeeper: Client environment:java.version=1.7.0_15
13/05/24 11:01:12 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation
13/05/24 11:01:12 INFO zookeeper.ZooKeeper: Client environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre

etc...

I have tried several different things from the client code itself, but none of the obvious ways have worked for me.

This is an example of something that didn't work:

Logger log = Logger.getLogger("log4j.logger.org.apache.zookeeper");
log.setLevel(Level.WARN);
like image 991
Eric Z Beard Avatar asked May 24 '13 15:05

Eric Z Beard


People also ask

What is the function of HBase ENV SH Apache HBase configuration file?

hbase-env.sh provides a handy mechanism to do this. HBase uses the Secure Shell (ssh) command and utilities extensively to communicate between cluster nodes. Each server in the cluster must be running ssh so that the Hadoop and HBase daemons can be managed.

What is HBase cluster?

HBase provides low latency random read and write access to petabytes of data by distributing requests from applications across a cluster of hosts. Each host has access to data in HDFS and S3, and serves read and write requests in milliseconds.

Which of the following API can be used for exploring HBase tables?

Basically, to perform CRUD operations on HBase tables we use Java client API for HBase. Since HBase has a Java Native API and it is written in Java thus it offers programmatic access to DML (Data Manipulation Language).


2 Answers

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

like image 57
Lorand Bendig Avatar answered Oct 02 '22 14:10

Lorand Bendig


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.

like image 32
giscard.faria Avatar answered Oct 02 '22 14:10

giscard.faria