您的位置:首页 > 编程语言 > Java开发

spring中log4j配置文件不放在classpath的根目录

2017-01-16 11:32 477 查看

前言

spring默认加载的是classpath根目录下面的log4j.properties,如果要放在其他目录,则需要按如下配置

在web.xml中配置

配置

<!-- 指定log4j配置文件log4j.properties的位置(如果是在classpath根路径下,可以不配置) -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:config/log4j.properties</param-value>
</context-param>

<!-- 配置spring中对于log4j的listener,注意该Listener要在spring的listener之前 -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring log4j web.xml