Arundev
Arundev

Reputation: 11

catalina.out daily rolling

I tried Log4j for rolling catalina.out as per below way. But it is creating duplicate log entries with date appended and current log getting written to this log rather than catalina.out file. Please suggest.

I am using tomcat 6 & 7

I followed steps as per below.

http://mifosforge.jira.com/wiki/display/MIFOS/Rolling+Tomcat+Logs

Upvotes: 0

Views: 9070

Answers (2)

German Attanasio
German Attanasio

Reputation: 23653

I guess that you are using the same logger in more than one line in the log4j.properties

log4j.rootLogger=INFO, file
log4j.logger.com.company.project=DEBUG, file

In the example below the appender called "file" will log all classes from root and classes in "com.company.project" will also log to "file". So you end up having two lines logged in "file".

To fix it, you need to remove "file" and use it only once, in the rootLogger for example.

log4j.rootLogger=INFO, file
log4j.logger.com.company.project=DEBUG

Upvotes: 1

Max
Max

Reputation: 842

Your instruction contains paragraph:

If you find that your logs have duplicate entries, then you should remove the changes you made to $CATALINA_HOME/conf/context.xml in step 6. You should use this log4j.properties file instead:

log4j.rootLogger=info, R
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.File=${catalina.home}/logs/catalina.out
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

We included these alternate instructions because the issue with duplicate entries happen on some platforms and not others.

Your problemm is probably this line:

log4j.rootLogger=info, R

Check if you forgot removing stdout from this line.

Upvotes: 1

Related Questions