如何在Hadoop 2中更改用户日志的日志级别?

amo*_*moe 3 java logging hadoop log4j hadoop2

我一直在尝试更改用户日志上的日志级别,即/var/log/hadoop-yarn/userlogs/application_<id>/container_<id>CDH 5.2.1上显示的文件.但是,无论我尝试什么,都只会INFO显示级别日志.我想启用TRACE级别日志进行调试.

到目前为止我尝试过的事情:

  • 将所有记录器设置为TRACE级别/etc/hadoop/conf/log4j.properties.
  • 设置mapreduce.map.log.levelmapreduce.reduce.log.levelmapred-site.xml.
  • 在提交之前设置mapreduce.map.log.levelmapreduce.reduce.log.level在作业配置中.
  • log4j.properties在我的作业jar文件中包含一个将根Log4j记录器设置为TRACE的文件.
  • 修改yarn-env.sh以指定YARN_ROOT_LOGGER=TRACE,console

这些都没有奏效 - 它们没有破坏任何东西,但它们对userlogs目录下的日志输出没有任何影响.修改yarn-env.sh 确实导致ResourceManager和NodeManager日志进入跟踪级别.不幸的是,这些对我的目的没用.

我出现以下错误/var/log/hadoop-yarn/userlogs/application_<id>/container_<id>/stderr可能是相关的.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/lib/zookeeper/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/hadoop-yarn/nm-local-dir/usercache/tomcat/appcache/application_1419961570089_0001/filecache/10/job.jar/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (org.apache.hadoop.ipc.Server).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Run Code Online (Sandbox Code Playgroud)

我不明白为什么log4j"无配置"消息会发生,因为log4j.properties作业jar文件的根目录下有一个指定根记录器的文件:

log4j.rootLogger=TRACE, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] %m%n
Run Code Online (Sandbox Code Playgroud)

我的代码不会故意使用SLF4J进行日志记录,它纯粹使用Log4j.

amo*_*moe 6

实际答案是设置yarn.app.mapreduce.am.log.level为您需要的级别,但是,至关重要的是,它需要在提交时在Hadoop作业配置中设置.无法在全局集群中设置它.群集全局将始终默认为INFO,因为它是硬编码的.

container-log4j.properties单独使用不起作用,因为YARN将覆盖命令行上的日志级别值.看到该方法addLog4jSystemPropertiesorg.apache.hadoop.mapreduce.v2.util.MRApps并用交叉引用org.apache.hadoop.mapreduce.MRJobConfig.

container-log4j.properties 确实会受到尊重,但它无法覆盖此属性设置的级别.