Log4j 1.2自定义loglevel与属性文件中的levelmatchfilter

时间:2014-09-15 12:04:35

标签: log4j

我尝试为自定义日志级别实现levelmatchfilter,并在属性文件中对其进行配置。 使用chrunchify loglevel的模板创建我的:     http://crunchify.com/java-how-to-create-your-own-logging-level-in-log4j-configuring-log4j/

配置我的属性文件如下:

log4j.rootLogger.level=DEBUG

# LOG4J daily rolling log files configuration
log4j.rootLogger=debug, DebugAppender, InfoAppender, ErrorAppender, ChangeAppender

#DebugAppender (Debug)
log4j.appender.DebugAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DebugAppender.File=./log/debug/ngpmt_debug.log
log4j.appender.DebugAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n
log4j.appender.DebugAppender.Threshold=DEBUG

#InfoAppender (Loud)
log4j.appender.InfoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.InfoAppender.File=./log/loud/ngpmt_info.log
log4j.appender.InfoAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n
log4j.appender.InfoAppender.Threshold=INFO

#ErrorAppender (Silent)
log4j.appender.ErrorAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ErrorAppender.File=./log/silent/ngpmt_error.log
log4j.appender.ErrorAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.ErrorAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ErrorAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n
log4j.appender.ErrorAppender.Threshold=WARN

#ChangeAppender (Changes)
log4j.appender.ChangeAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ChangeAppender.File=./log/silent/ngpmt_changes.log
log4j.appender.ChangeAppender.File.filter.a=org.apache.log4j.varia.LevelMatchFilter     
log4j.appender.ChangeAppender.File.filter.a.LevelToMatch=CHANGE#at.xtention.pqm.ngpmt.gui.helpers.Change 
log4j.appender.ChangeAppender.File.filter.a.AcceptOnMatch=true    
log4j.appender.ChangeAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.ChangeAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.ChangeAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n

我有3个不同范围的日志文件。除此之外,我想要一个只记录CHANGE-Level消息的日志文件。

0 个答案:

没有答案