web.xml中的配置:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/log4j2.properties</param-value>
</context-param>
<!-- 每60秒扫描配置文件的变化 -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<!-- 配置log4j监听器 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
控制台日志:
十一月 10, 2015 10:56:04 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
十一月 10, 2015 10:56:04 下午 org.apache.catalina.core.ApplicationContext log
信息: Set web app root system property: 'webapp.root' = [D:\MyEclipse2014\plugins\apache-tomcat-8.0.26\webapps\gloomy]
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
十一月 10, 2015 10:56:04 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing log4j from [D:\MyEclipse2014\plugins\apache-tomcat-8.0.26\webapps\gloomy\WEB-INF\log4j2.properties]
十一月 10, 2015 10:56:05 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
十一月 10, 2015 10:56:11 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\MyEclipse2014\plugins\apache-tomcat-8.0.26\webapps\gloomy has finished in 10,190 ms