Log4J: duplicate Lines in output?

Ever see duplicate lines in your log4j output? Something like this perhaps:

2006-08-12 18:30:00,783 DEBUG  com.cml.etech.eForms.sys.AbstractQuartzJobRouter - Start of execute
2006-08-12 18:30:00,783 DEBUG  com.cml.etech.eForms.sys.AbstractQuartzJobRouter - Start of execute
2006-08-12 18:30:00,783 DEBUG  com.cml.etech.eForms.sys.QuartzJobServletRouter - About to issue getContent() request
2006-08-12 18:30:00,783 DEBUG  com.cml.etech.eForms.sys.QuartzJobServletRouter - About to issue getContent() request

The reason could be duplicate loggers specified in your log4j configuration. For example:

log4j.rootLogger=INFO, file
log4j.logger.com.cml.etech=debug, file

This is telling log4j that the root logger should output to a file appender called "file" and that all classes in com.cml.etech should also log to a file appender called "file". The fix is easy: just remove "file" from the second logger definition, as per below.

log4j.rootLogger=INFO, file
log4j.logger.com.cml.etech=debug

Popular Posts