Reputation: 2365
I am currently fine-tuning my log4j config of a relatively large project. Currently I have not yet configured the log-levels for all locations that could create log entries.
I would like to have log4j have some sort of fallback appender to log all messages for which no other appender has been configured. So if for example I have a log message to:
log to: a.b.c.d:WARN
and have an appender configured to log packages a.b.c with level INFO, then the output is logged to that appender.
If however I have no appender configured to handle a.b.c.d then the fallback should be used.
If I would have configured my a.b.c Appender to level FATAL, then nothing should be logged at all, as I deliberately configured log4j to leave these messages away.
I hope I was able to explain what I want to do :-)
Any suggestions?
Chris
Upvotes: 0
Views: 1158
Reputation: 46219
If you don't want to get everything in you root logger, you can set the
additivity = "false"
on the other loggers. Then the logs won't propagate.
Upvotes: 1
Reputation: 40036
I think @Keppil seems mixing up something.
Additivity is something set on Logger, and it control how the settings of parent loggers (includes appender) propagate to the logger.
So, in OP's case, you may do something like this:
Root Logger -> Appender1
Logger a.b.c -> additivity = false, Appender2
By doing so, a.b.c (and all its children) will send its log to Appender2, while all other loggers will send to Appender1.
Upvotes: 0