Hadoop log Output

Source: Internet
Author: User

Hadoop has its own path and configuration method for logging.
Print Log method: LOG4J,SLF4J, such as logging methods, system logs and so on.
Definition of the path and file name of the log record: There are related settings in Mapred-site.xml.
  1. <? XML version="1.0"?>
  2. <? Xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <!--Put Site-specific property overrides in this file.--
  4. < Configuration >
  5. <!--Jobtracker's master address--
  6. < Property >
  7. < name >mapred.job.tracker</name>
  8. < value >192.168.75.130:9001</value>
  9. </ Property >
  10. < Property >
  11. <!--Hadoop log output specified directory--
  12. < name > mapred.local.dir </ name >   
  13. < value >/root/hadoop1.2/mylogs</value>
  14. </ Property >
  15. </ Configuration >
Configuration of log content
Modify the Log4j.properties file. At the end of the file, add the following:
#为写日志的操作取个名字, Mydfsclient. Used to get an instance of the log in Dfsclient. and specify the output mode as a custom out
Log4j.logger.mydfsclient=debug,out
#设置OUT的输出方式为输出到文件
Log4j.appender.out=org.apache.log4j.fileappender
#设置文件路径
Log4j.appender.out.file=${hadoop.log.dir}/dfsclient.log
#设置文件的布局
Log4j.appender.out.layout=org.apache.log4j.patternlayout
#设置文件的格式
log4j.appender.out.layout.conversionpattern=%d{iso8601}%p%c:%m%n
#设置该日志操作不与父类日志操作重叠
Log4j.additivity.mydfsclient=false
Log Output
Modifying the Dfsclient class
This is simply to verify the correctness of the process and to add more meaningful log content later.
First declare a log instance in the Dfsclient class:
public static final Logger mylog = Logger.getlogger (Enstsas.class);
In the read (byte buf[], int off, int len) function, add the following code:
Mylog.info ("Read Block!!!!");
if (currentblock!=null)
Mylog.info ("Read Block:" +currentblock.getblockid ());

Hadoop log Output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.