log4j:WARN No appenders could be found for logger 报错

原因:缺少文件,在resources文件夹中添加log4j.properties文件(名字必须相同)

log4j:WARN No appenders could be found for logger 报错

写入以下代码:


# Configure logging for testing: optionally with log file
log4j.rootLogger=WARN, stdout
# log4j.rootLogger=WARN, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= %d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=target/spring.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern= %d %p [%c] - %m%n

ok,就不报错了

上一篇:log4j:WARN No appenders could be found for logger


下一篇:java-从shp文件读取坐标并计算距离