log4j - Log4J 禁用特定类别的多个附加任务的日志记录

  显示原文与译文双语对照的内容
129 2

我设置 Log4J 以使用多个附加组件。然而,我希望将默认日志级别设置为调试,并将特定类的日志记录限制为以上。我为,提供了工作,但不是DCSLOAD和DCSPROC提供程序。我做错什么了?

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger = CA, FA
# CA is set to be a ConsoleAppender.
log4j.appender.CA=org.apache.log4j.ConsoleAppender
# CA uses PatternLayout.
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{3} %x - %m%n
# FA uses PatternLayout.
log4j.appender.FA=org.apache.log4j.RollingFileAppender 
log4j.appender.FA.File=${catalina.base}/logs/dcs.log 
log4j.appender.FA.layout=org.apache.log4j.PatternLayout 
log4j.appender.FA.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{3} %x - %m%n
log4j.appender.FA.MaxFileSize=1024KB
log4j.appender.FA.MaxBackupIndex=100
# DCSPROC, DCSLOAD and DCSDB are all File Appenders to different targets
log4j.appender.DCSPROC=org.apache.log4j.RollingFileAppender
log4j.appender.DCSPROC.File=${catalina.base}/logs/dcs_process.log 
log4j.appender.DCSPROC.layout=org.apache.log4j.PatternLayout 
log4j.appender.DCSPROC.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{3} %x - %m%n
log4j.appender.DCSPROC.MaxFileSize=1024KB
log4j.appender.DCSPROC.MaxBackupIndex=100
log4j.appender.DCSLOAD=org.apache.log4j.RollingFileAppender
log4j.appender.DCSLOAD.File=${catalina.base}/logs/dcs_business.log 
log4j.appender.DCSLOAD.layout=org.apache.log4j.PatternLayout 
log4j.appender.DCSLOAD.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{3} %x - %m%n
log4j.appender.DCSLOAD.MaxFileSize=1024KB
log4j.appender.DCSLOAD.MaxBackupIndex=100
log4j.appender.DCSDB=org.apache.log4j.RollingFileAppender
log4j.appender.DCSDB.File=${catalina.base}/logs/dcs_database.log 
log4j.appender.DCSDB.layout=org.apache.log4j.PatternLayout 
log4j.appender.DCSDB.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c{3} %x - %m%n
log4j.appender.DCSDB.MaxFileSize=1024KB
log4j.appender.DCSDB.MaxBackupIndex=100
# set default logging level for outputs
log4j.logger.CA = DEBUG
log4j.logger.FA = DEBUG
log4j.logger.DCSDB = DEBUG, DCSDB
log4j.logger.DCSPROC = DEBUG, DCSPROC
log4j.logger.DCSLOAD = DEBUG, DCSLOAD
log4j.additivity.DCSDB=false
log4j.additivity.DCSPROC=false
log4j.additivity.DCSLOAD=false
#This works
log4j.logger.LoginServlet=INFO, FA
#These two do not 
log4j.logger.LoginServlet=INFO, DCSLOAD
log4j.logger.LoginServlet=INFO, DCSPROC
时间:原作者:0个回答

138 1

 log4j.logger.DCSDB = DEBUG, DCSDB
 log4j.logger.DCSPROC = DEBUG, DCSPROC
 log4j.logger.DCSLOAD = DEBUG, DCSLOAD

 log4j.logger.DCSDB = DEBUG
 log4j.logger.DCSPROC = DEBUG
 log4j.logger.DCSLOAD = DEBUG
原作者:
...