log4j第二个记录器错误

时间:2012-05-07 11:29:57

标签: log4j

为什么我的第二个记录器错误但第一个记录器错误?

错误:

log4j:WARN No appenders could be found for logger (StatQueryDobadoCategory).
log4j:WARN Please initialize the log4j system properly.

这是log4j.properties:

log4j.category.ThingsPerMinuteGraphCategory=DEBUG, ThingsPerMinuteGraphAppender
log4j.appender.ThingsPerMinuteGraphAppender=org.apache.log4j.RollingFileAppender
log4j.appender.ThingsPerMinuteGraphAppender.File=./logs/ThingsPerMinuteGraph.log
log4j.appender.ThingsPerMinuteGraphAppender.MaxFileSize=20MB
log4j.appender.ThingsPerMinuteGraphAppender.MaxBackupIndex=5
log4j.appender.ThingsPerMinuteGraphAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ThingsPerMinuteGraphAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} - %m
log4j.additivity.ThingsPerMinuteGraphCategory=false

log4j.category.StatQueryDobadoCategory=DEBUG, StatQueryDobadoAppender
log4j.appender.StatQueryDobadoAppender=org.apache.log4j.RollingFileAppender
log4j.appender.StatQueryDobadoAppender.File=./logs/StatQueryDobadoCategory.log
log4j.appender.StatQueryDobadoAppender.MaxFileSize=20MB
log4j.appender.StatQueryDobadoAppender.MaxBackupIndex=5
log4j.appender.StatQueryDobadoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.StatQueryDobadoAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} - %m
log4j.additivity.StatQueryDobadoCategory=false

1 个答案:

答案 0 :(得分:0)

图书馆似乎无法访问log4j.properties。

  1. 如果您只将log4j用于java项目,请将属性文件放入源文件夹

  2. 如果你使用log4j作为j2ee项目,比如spring + hibernate,把log4j.properties放到WEB-INF文件夹中,并在项目的属性文件中设置属性文件的路径

    
    <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>