2 gkmmg gkmmg 于 2016.09.26 11:30 提问

log4j输出不到项目相对路径WEB-INF下,求大神帮忙解决

web.xml的配置,按照网上说的,Log4jConfigListener已经放到了spring监听器的前面了,但是还是不能输出到相对路径中。

 <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>Blog.root</param-value>
    </context-param>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>
    <context-param>
        <param-name>log4jRefreshInterval</param-name>
        <param-value>600000</param-value>
    </context-param>
    <!-- 加载log4j配置文件 -->
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
 log4j.rootCategory=DEBUG, CONSOLE , INF_OUT
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5.5p %d{HH\:mm\:ss-SSS}]\u4FE1\u606F\: %m%n

log4j.appender.INF_OUT=org.apache.log4j.RollingFileAppender
log4j.appender.INF_OUT.Threshold=info
log4j.appender.ERROR_OUT.Append=true
log4j.appender.INF_OUT.File=${Blog.root}/WEB-INF/logs/Blog.log
log4j.appender.INF_OUT.MaxFileSize=1024KB
log4j.appender.INF_OUT.MaxBackupIndex=20
log4j.appender.INF_OUT.layout=org.apache.log4j.PatternLayout
log4j.appender.INF_OUT.layout.ConversionPattern=[%d - %p %t %c]\u4FE1\u606F %m%n

log4j.logger.org.springframework=WARN
log4j.logger.org.hibernate=INFO
log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN

图片说明

1个回答

Veggiel
Veggiel   2016.09.26 13:16

log4j.appender.logfile.File=${Blog.root}/WEB-INF/logs

Csdn user default icon
上传中...
上传图片
插入图片