0

I have the following configs for my logs :

log4j.rootCategory=INFO, RollLogFile
log4j.logger.ReportLog=INFO,ReportLog

After, i set two appenders for my logs and some properties. Im doing this in my code:

reportLogger = LogManager.getLogger("ReportLog");

And after that

reportLogger.info("blabla bla bla ");

Why this line is also logged in RollLogFile`s file?

0

1 Answer 1

1

Because of Appender additivity:

Each enabled logging request for a given logger will be forwarded to all the appenders in that logger as well as the appenders higher in the hierarchy. In other words, appenders are inherited additively from the logger hierarchy. For example, if a console appender is added to the root logger, then all enabled logging requests will at least print on the console. If in addition a file appender is added to a logger, say C, then enabled logging requests for C and C's children will print on a file and on the console. It is possible to override this default behavior so that appender accumulation is no longer additive by setting the additivity flag to false.

Not the answer you're looking for? Browse other questions tagged or ask your own question.