0
votes

I setup Log4J to use multiple appenders. This is working fine. However, I want to set the default log level to one appender to DEBUG, and restrict logging for a specific class to INFO and above. What I came up with works for the FA appender, but not the DCSLOAD and DCSPROC appenders. What am I doing wrong?

# 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
1
OK, I see what I needed to do. I changed my class-level debugging to just this, and it appears to be working now: log4j.logger.LoginServlet=DEBUGMichael Sobczak

1 Answers

0
votes

change these:

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

to

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