首页 > 代码库 > log4j:WARN No appenders could be found for logger错误

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

用Hibernate连上数据库之后不能插入数据,报了这个错误。

直接写我的解决办法:
src下面新建file名为log4j.properties内容如下:

# 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

 

保存之后,不报错了

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