项目中必须是在使用spring
web.xml加入
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webApp.root</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>600000</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
然后log4j.properties里面指定文件路径的时候就可以用${webApp.root}/
log4j.appender.info.File=${webApp.root}/WEB-INF/logs/info.log
同时你的web项目必须有/WEB-INF/logs这个目录
posted on 2008-05-21 09:29
交口称赞 阅读(5729)
评论(4) 编辑 收藏