web.xml里添加
<!-- 加载log4j的配置文件log4j.properties -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<!-- 设定刷新日志配置文件的时间间隔,这里设置为10s -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>10000</param-value>
</context-param>
<!-- 加载Spring框架中的log4j监听器Log4jConfigListener -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- 为避免项目间冲突,定义唯一的 webAppRootKey -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>scheduleProject</param-value>
</context-param>
-------
log4j.properties配置
### #配置根Logger ###
log4j.rootLogger=debug,stdout
### 输出到控制台 ###
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{yyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n