简体   繁体   中英

Log4j, different appenders, same package and an individual class, write to different files?

I normally associate a package to an appender. But in this one case, this class is writing a lot of logs I want to filter out to a different appender. But the class is in the same package as my other classes.

I am trying to do this:

log4j.logger.com.app=DEBUG,MainAppender
log4j.logger.com.app.webservice.Web=DEBUG,WSAppender

I want the WSAppender to write to one file but I DON'T want the same logs from the MainAppender. Right now, the logs from WSAppender also appear in MainAppender.

You need to set additivity=false on the child logger.

See example here .

log4j.additivity.com.app.webservice.Web = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM