运行IDEA出现log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell).问题解决方法

报错

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

解决步骤:

1.在src/main/resources目录下创建log4j.properties

右击resource→New→Resource Bundle

运行IDEA出现log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell).问题解决方法_第1张图片

 name为log4j,不要勾选,直接点击ok

运行IDEA出现log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell).问题解决方法_第2张图片

 2.创建成功后在里面填写如下内容

hadoop.root.logger=DEBUG, console
log4j.rootLogger = DEBUG, 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

3.在main函数中加入

BasicConfigurator.configure(); 

4.Rerun一下就可以正常运行了

你可能感兴趣的:(解决运行代码时的问题,log4j,apache,intellij-idea,hadoop)