how to write java Log file using the logger api while using hadoop how to write java Log file using the logger api while using hadoop hadoop hadoop

how to write java Log file using the logger api while using hadoop


Hadoop comes with preconfigured log4j. All you have to do is import two classes:

import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;

And now you can define logger inside your mappers, reducers and wherever you want:

private static final Log LOG = LogFactory.getLog(MyClass.class);

And log what you need:

LOG.info("My message");

The messages will show up during job execution. You can tweak log4j configuration with

conf/log4j.properties