Log4j - Have multiple appenders write to the same file with one that always logs

后端 未结 4 1236
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 21:43

I have a log4j appender defined like:

log4j.logger.com.example = DEBUG, filelog

log4j.appender.filelog=org.apache.log4j.DailyRollingFileAppender
log4j.appen         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 22:23

    I got this to work by using AsyncAppenders. I had my main appender which specified a file to log to, and had my other appenders refer to it.

    e.g.

    
        
    
    
    
        
    
    
    
        
    
    

    You can add other filters, or whatever to the other appenders. As far as I can tell with my own app, the logs seem to roll, and the appender filters work as expected.

提交回复
热议问题