Srivatsa N
Srivatsa N

Reputation: 2321

Rolling catalina.YYYY-MM-DD.log file

For some specific reason I need to retain both my app specific log and catalina.log. I have configured log4j to use RollingFileAppender for my app specific logs and it is working fine. Is there any way to use similar logging mechanism for catalina.logs also.

Can I do this by somehow tweaking the logging.properties under conf.

Upvotes: 0

Views: 1884

Answers (1)

Govil
Govil

Reputation: 2054

You can use logrotate. If you run ubuntu. Create this file

/etc/logrotate.d/tomcat

Copy the following contents into the above file

/var/log/tomcat/catalina.out {  
 copytruncate  
 daily  
 rotate 7  
 compress  
 missingok  
 size 5M  

}

Make sure that the path /var/log/tomcat/catalina.out above is adjusted to point to your tomcat’s catalina.out

daily - rotates the catalina.out daily

rotate – keeps at most 7 log files

compress – compresses the rotated files

size – rotates if the size of catalina.out is bigger than 5M

Thats it.

Upvotes: 1

Related Questions