log4j duplicated logs between Catalina.out and log file

1.4k views Asked by At

I am trying to optimise the log4j library for an web application in java. We have a server in Tomcat7 and all the configs done is working as except but i noticed that have a duplicated logs between file created by LOG4J properties and catalina.out.

#LOG4J configuration
log4j.rootLogger=INFO, Appender1,Appender2

log4j.appender.Appender1=org.apache.log4j.ConsoleAppender
log4j.appender.Appender1.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender1.layout.ConversionPattern=%-7p %d [%t] %c - %m%n

log4j.appender.Appender2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.Appender2.File=${catalina.base}/logs/logfile.out
log4j.appender.Appender2.layout=org.apache.log4j.PatternLayout
log4j.appender.Appender2.layout.ConversionPattern=%-7p %d [%t] %c - %m%n
log4j.appender.Appender2.DatePattern='-'yyyyMMdd'.log'

All the logs listed in logfile.out are include in catalina.out.

What i can i do?

1

There are 1 answers

0
Vikas Sachdeva On BEST ANSWER

ConsoleAppender is printing logs in catalina.out so removing ConsoleAppender from your log4j configuration file will solve your problem.

Generally, in a web application, ConsoleAppender is not used.