log4j:WARN No appenders could be found for logger 问题

Maven项目,运行程序出现log4j警告代码如下:

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.(截图为)


需要把log4j.properties文件放在main文件夹的resources下,如图:

log4j:WARN No appenders could be found for logger 问题_第1张图片

log4j.properties文件的代码为:

# Global logging configuration
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

这样问题就解决了,如下图我的项目就再没有警告了

log4j:WARN No appenders could be found for logger 问题_第2张图片

不能把log4j文件上传,有需要的私信我吧

你可能感兴趣的:(WARN)