Files and Directories Used in this Exercise
In this Hands-On Exercise, you will practice using log4j with MapReduce.
Modify the Average Word Length program you built in the Using ToolRunner and Passing Parameters exercise so that the Mapper logs a debug message indicating whether it is comparing with or without case sensitivity.
Enable Mapper Logging for the Job
1. Before adding additional logging messages, try re-running the toolrunner exercise solution with Mapper debug logging enabled by adding -Dmapred.map.child.log.level=DEBUG to the command line. E.g.
2. Take note of the Job ID in the terminal window by using mapred job command:
3. When the job is complete, view the logs. In a browser on your VM, visit the Job Tracker UI: http://localhost:50030/jobtracker.jsp. Find the job you just ran in the Completed Jobs list and click its Job ID. E.g.:
4. In the task summary, click map to view the map tasks.
5. In the list of tasks, click on the map task to view the details of that task:
6. Under Task Logs, click "All". The logs should include both INFO and DEBUG message.
Add Debug Logging Output to the Mapper
7. Copy the code from toolrunner project to the logging project stubs package.
8. Using log4j to output a debug log message indicating whether the Mapper is doing case sensitive or insensitive mapping:
9. Following the eariler steps, test your code with Mapper debug logging enabled. View the map task logs in the Job Tracker UI to confirm that your message is included in the log. (Hint: search for LetterMapper in the page to find your message.)
10. Optional: Try running map logging set to INFO (the default) or WARN instead of DEBUG and compare the log output.