log4j additivity, category logging level and appender threshold
Posted
by
GBa
on Stack Overflow
See other posts from Stack Overflow
or by GBa
Published on 2012-04-09T23:01:51Z
Indexed on
2012/04/09
23:29 UTC
Read the original article
Hit count: 623
I'm having troubles understanding the relation between additivity, category logging level and appender threshold...
here's the scenario (my log4j.properties file):
log4j.category.GeneralPurpose.classTypes=INFO, webAppLogger
log4j.additivity.GeneralPurpose.classTypes=true
log4j.category.GeneralPurpose=ERROR, defaultLogger
log4j.additivity.GeneralPurpose=false
log4j.appender.webAppLogger=org.apache.log4j.RollingFileAppender
log4j.appender.webAppLogger.File=webapps/someWebApp/logs/webApp.log
log4j.appender.webAppLogger.MaxFileSize=3000KB
log4j.appender.webAppLogger.MaxBackupIndex=10
log4j.appender.webAppLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.webAppLogger.layout.ConversionPattern=%d [%t] (%F:%L) %-5p - %m%n
log4j.appender.webAppLogger.Encoding=UTF-8
log4j.appender.defaultLogger=org.apache.log4j.RollingFileAppender
log4j.appender.defaultLogger.File=logs/server.log
log4j.appender.defaultLogger.MaxFileSize=3000KB
log4j.appender.defaultLogger.MaxBackupIndex=10
log4j.appender.defaultLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.defaultLogger.layout.ConversionPattern=%d [%t] (%F:%L) %-5p - %m%n
log4j.appender.defaultLogger.Encoding=UTF-8
insights: category GeneralPurpose.classTypes is INFO category GeneralPurpose.classTypes has additivity TRUE category GeneralPurpose is ERROR category GeneralPurpose has additivity FALSE
with the current configuration I would have assumed that INFO messages sent to category GeneralPurpose.classTypes.* would be only logged to webAppLogger since the parent logger (cateogry) is set with ERROR level logging. However, this is not the case, the message is logged twice (one in each log file). Looks like the ERROR logging level for the parent category is not taken into consideration when the event is sent as part of additivity...
- is my observation correct or am I missing something ?
- how should I alter the configuration in order to achieve only ERROR level loggings in server.log ?
thanks,
GBa.
© Stack Overflow or respective owner