2019独角兽企业重金招聘Python工程师标准>>>
在启动tomcat时候报:
log4j:WARN No appenders could be found for logger(org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
我的log4j.properties在类路径下,配置如下:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=./logs/app.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
#struts
log4j.logger.com.opensymphony.xwork2=INFO
log4j.logger.org.apache.struts2=DEBUG
#spring
log4j.logger.org.springframework=INFO
#mybatis
log4j.logger.java.sql.ResultSet=INFO
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.rootLogger=warn, stdout, R
log4j.logger.cn.xyz=DEBUG
解决办法是在web.xml文件加上:
但是有一点必须注意,就是log4jConfigLocation监听器要放在spring初始化监听器的前面。这点应该很好理解...