Spring中使用LOG4J

农码经神 2009-12-12

Spring中使用LOG4J   1.在web.xml中添加上下文初始化参数

<context-param> 
  <param-name>webAppRootKey</param-name> 
  <param-value>path</param-value> 
</context-param> 

<context-param> 
  <param-name>log4jConfigLocation</param-name> 
  <param-value>/WEB-INF/log4j.properties</param-value> 
</context-param>

2.添加日志监听器

<listener> 
  <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
</listener>

3.添加log4j.properties文件

获取日志文件输入路径${path}/WEB-INF

相关推荐