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?
ConsoleAppender
is printing logs incatalina.out
so removingConsoleAppender
from yourlog4j
configuration file will solve your problem.Generally, in a web application,
ConsoleAppender
is not used.