如何为同一个包中的类配置Log4j Multiple Appender

时间:2017-03-31 07:13:18

标签: java logging log4j

请帮助纠正信息级别阈值的appender重新路由以更正包中类的appender。以下是属性文件    `

# Root logger option
    log4j.rootLogger=INFO, ffile, stdout ,sfile    
    # Direct log messages to stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
    # Direct log messages to a log file
    log4j.appender.ffile=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.ffile.Threshold=ERROR
    log4j.appender.ffile.File=failure.log
    log4j.appender.ffile.layout=org.apache.log4j.PatternLayout
    log4j.appender.ffile.layout.ConversionPattern=%d{ISO8601} %c{1}: - %m%n
    # Direct log messages to a log file
    log4j.appender.sfile=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.sfile.Threshold=INFO
    log4j.appender.sfile.File=success.log
    log4j.appender.sfile.layout=org.apache.log4j.PatternLayout
    log4j.appender.sfile.layout.ConversionPattern=%d{ISO8601} %c{1}: - %m%n
    #Additivity to stop the mix/repeate of logs in multiple appenders
    log4j.additivity.com.rp.handler.AsynchSeeder=false
    log4j.additivity.com.rp.handler=false
    #Configured logger to route to the appender files. Failing
    log4j.logger.com.rp.handler.AsynchSeeder=ERROR, stdout, ffile
    log4j.logger.com.rp.handler=INFO, stdout, sfile
    #Suppress all low level for open source 3rdparty
    log4j.logger.org.apache=WARN

`

0 个答案:

没有答案