Log4j, Spring MVC, No appenders could be found for logger
https://stackoverflow.com/questions/9691456/log4j-spring-mvc-no-appenders-could-be-found-for-logger
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Place the spring Log4jConfigListener as the first listener in your web.xml.
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
You set upp the location of the log4j properties in a context-param but you do not need to do this if it is placed on the classpath.
An example is ..
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/resources/log4j.properties</param-value>
</context-param>
解决问题的关键是 把 Log4jConfigListener 放在 ContextLoaderListener 之前…
┓( ´∀` )┏
还有一种掩耳盗铃的方式…
If you have:
log4j.rootLogger=WARN
Change it to:
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
log4j:WARN No appenders could be found for logger in web.xml