DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

yuan has posted 7 posts at DZone. View Full User Profile

Spring 应用中添加log4j 配置

12.26.2007
| 5134 views |
  • submit to reddit
        // description of your code here

<!-- 定义一个key name, 这个key name 在运行时指向当前web app的根目录 --->
  <context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>petstore.root</param-value>
  </context-param>
  <!-- 定义一个log4j 配置文件的路径名称 -->
  <context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/log4j.properties</param-value>
  </context-param>
  <!-- 使用listener 配置 log4j  -->
  <listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  </listener>