Bruno Nogueira
Bruno Nogueira

Reputation: 53

log4j duplicated logs between Catalina.out and log file

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?

Upvotes: 2

Views: 1586

Answers (1)

Vikas Sachdeva
Vikas Sachdeva

Reputation: 5813

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.

Upvotes: 1

Related Questions