log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.o

时间:2023-03-09 07:48:52
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.o

上面的报错是在本地java调试(windows) hadoop集群 出现的

解决方案:

在resources文件夹下面创建一个文件log4j.properties(这个其实hadoop安装目录下的 etc/hadoop/log4j.properties 同名,我尝试拿过来用,发现还是不行报错信息如下)

log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

所以我把里面的内容替换成

hadoop.root.logger=INFO, console
log4j.rootLogger = INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n

  然后右键点击run 执行就可以了