dcsimg
Anything is logged twice
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amir_Pashazadeh
Posted On:   Monday, May 24, 2004 11:22 PM

Hi My project has a log4j.properties file with following contents: # Set root logger level to DEBUG and its only appender to A1. log4j.rootLogger=FATAL, A2 log4j.logger.com.ito.lms=DEBUG, A1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d %-4r [%t] %-5p %c - %L - %m%n # A2 is set to be a ConsoleAppender. log4j.appender.A2=org.apache.log4j.ConsoleAppender # A2 uses PatternLayout. log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A   More>>

Hi



My project has a log4j.properties file with following contents:

			

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=FATAL, A2
log4j.logger.com.ito.lms=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-4r [%t] %-5p %c - %L - %m%n

# A2 is set to be a ConsoleAppender.
log4j.appender.A2=org.apache.log4j.ConsoleAppender

# A2 uses PatternLayout.
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d %-4r [%t] %-5p %c - %L - %m%n



But everything I log with "com.ito.lms" category is logged twice, why is it so!? I'm sure the second one is because of A2 appender (I've changed its layout pattern and the second log's pattern changed), which must be just append when log is of level FATAL or more, not DEBUG! Why is it so?
   <<Less

Re: Anything is logged twice

Posted By:   Adrien_Meaudre  
Posted On:   Tuesday, June 1, 2004 05:16 AM

Hi,



Everything is logged twice because each event logged through your "com.ito.lms" logger is also logged by the root logger.



To avoid this, simply add another configuration parameter for the "com.ito.lms" logger (for example just below the line where the logger is defined) :



log4j.additivity.com.ito.lms=false



This tells that any event logged by this logger should not be propagated to the ancestor logger.



Hope this can help.

Adrien Meaudre
About | Sitemap | Contact