Monday, May 18, 2015

Log4j in Map Reduce programming

Problem : How to use Log4j in Map Reduce programming

Solution :

Include Log4j jar file in your project.
In your mapper class, use log4j as :



private static final Logger sLogger = Logger.getLogger(TwitterMapper.class); 
   protected void map(LongWritable key, Text value, Context context)
           throws java.io.IOException ,InterruptedException
           {
                sLogger.info("          ");
            }  
 

When the program is executed , look for following line :

15/05/19 07:06:08 INFO mapreduce.Job: The url to track the job: http://localhost:8088/proxy/application_1431707941929_0002/

This is telling the path where logs are created. 

In the browser, http://localhost:8088

Tools > Logs > UserLogs > application_1431707941929_0002 (id will be different in your scenario )

Browse through the files to find the logs you have written in your map reduce code.

And that's it :)

Have a good day ..
Happy Hadooping !!

No comments:

Post a Comment