Rotate catalina.out log

fjodors
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2015

Hello

I am trying to configure log4j.properties to rotate catalina.out log using DailyRollingFileAppender or RollingFileAppender, however I am not able to achieve such configuration.

I tried following:

1) DailyRollingFileAppender

"tomlog" in rootLogger definition

log4j.rootLogger=WARN, console, filelog, tomlog

Then parameters to rotate each minute as an example

# DailyRollingFileAppender. Rotate catalina.out log
#####################################################
log4j.appender.tomlog = org.apache.log4j.DailyRollingFileAppender
log4j.appender.tomlog.File = /opt/atlassian/jira/logs/catalina.out
log4j.appender.tomlog.Append = true
log4j.appender.tomlog.Encoding = UTF-8
log4j.appender.tomlog.DatePattern = '.'yyyy-MM-dd-HH-mm'.test.log'
log4j.appender.tomlog.layout = org.apache.log4j.PatternLayout
log4j.appender.tomlog.layout.ConversionPattern = %d [%t] %-5p %c- %m%

However after Jira restart I see that Jira creates some files but the latest entries was recorded in "catalina.out.2015-05-27-10-59.test.log", not in catalina.out

catalina.out.2015-05-27-10-59.test.log
catalina.out.2015-05-27-11-22.test.log
catalina.out.2015-05-27-11-04.test.log
catalina.out.2015-05-27-11-01.test.log
catalina.out.2015-05-27-11-00.test.log

 

2) RollingFileAppender

"tomlog" in rootLogger definition

log4j.rootLogger=WARN, console, filelog, tomlog

Parameters to keep 100KB size of catalina.out and remove previous catalina logs except last 10 files

log4j.appender.tomlog=org.apache.log4j.RollingFileAppender
log4j.appender.tomlog.File=/opt/atlassian/jira/logs/catalina.out
log4j.appender.tomlog.MaxFileSize=100KB
log4j.appender.tomlog.MaxBackupIndex=10
log4j.appender.tomlog.layout=org.apache.log4j.PatternLayout
log4j.appender.tomlog.layout.ConversionPattern=%p %t %c - %m%n

This configuration doesn't work also- catalina.out grows more then 100KB

 

Could help me to configure catalina.out log file rotation?

 

Thanks,

Fyodor

 

 

1 answer

1 vote
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2015

Are you on a Linux box? Something like logrotate is better I suppose:

 

fjodors
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2015

Hello Thanks for article, but is there possibility configure log4j for this? regards, Fyodor

Suggest an answer

Log in or Sign up to answer