Why doesn't Log4j rootLogger filter log events according to event level?

Why doesn't Log4j rootLogger in my application filter log events by level? In my log4j.propertiesI have several registrars:

log4j.rootLogger=info,stdout
log4j.logger.com.name.myapp=debug,myapp
log4j.logger.org.castor=debug,castor
log4j.logger.org.exolab.castor=debug,castor
log4j.logger.org.hibernate=debug,hibernate
log4j.logger.org.springframework=debug,spring

Each of the registrars receives and records a lot of log events at levels DEBUGand above, which I expect and wish. Nevertheless rootLogger, despite the fact that it is set to a level INFO, it displays all these events, including events DEBUGthat I do not expect, and not what I want. Instead, I would expect it to filter events DEBUG, but only display events at a level INFOabove ( WARN, ERRORand FATAL), which is also what I want. Why does rootLogger display all events?

+4
source share
3 answers

See this answer to a similar question about the logging chain in Log4j:

Log4j, ( ). , . , , !

, , , , , appender .

, . - :

log4j.additivity.com.name.myapp=false
log4j.additivity.org.castor=false
log4j.additivity.org.exolab.castor=false
log4j.additivity.org.hibernate=false
log4j.additivity.org.springframework=false

, , INFO (DEBUG TRACE):

log4j.appender.stdout.Threshold=info
+5

, Logger.getRootLogger()? , . , , stdout ; .

+2

, intro. , . debug , . , .

If you want to inherit the root logger level, get rid of the level specification in your log configurations.

+1
source

All Articles