SpringMvc mybatis的log4j文件的配置

J2EE 码拜 8年前 (2016-05-28) 850次浏览
SpringMvc mybatis的log4j文件应该配置在哪,怎么配置
解决方案

5

放到哪里都行,指定了路径就行,默认是classpath下

5

大哥,你怎么放在web-inf下呢,一般放在src目录下的,然后将路径给spring-context.xml下配置

10

放在和spring配置同一个目录就可以

25

Spring加载log4j.properties,它提供了一个Log4jConfigListener,本身就能通过web.xml配置从指定位置加载log4j配置文件和log4j的输出路径,要注意的是
Log4jConfigListener必须要在Spring的Listener之前。
web.xml
<!– 设置由Sprng载入的Log4j配置文件位置 –>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/classes/log4j.properties</param-value>
</context-param>
<!– Spring刷新Log4j配置文件变动的间隔,单位为毫秒 –>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>10000</param-value>
</context-param>

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


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明SpringMvc mybatis的log4j文件的配置
喜欢 (0)
[1034331897@qq.com]
分享 (0)