catalina.out log rotation



I am interested in catalina.out log file rotation, I have an application where logging to catalina.out is very huge, say 0.5 MB / sec.

So I have written one script to handle this which is shown below.


# crontab -l | grep catalina

0,30 * * * * bash /  >/dev/null 2>&1


# more /




$CATLOC /catalina.out >> /catalina_backup.out à take a backup and then handle this file rotation using logadm

$SEDLOC '' catalina.out > catalina.out à Empty this file


There are two cases here


1.)     The below is normal behavior where not much logging

# ls -ltrh catalina*

-rw-r-----   1 ems      ems          15K Jan 31 12:07 catalina.2012-01-31.log

-rw-r-----   1 ems      ems         3.9K Feb  1 06:26 catalina.2012-02-01.log

-rw-r-----   1 ems      ems         345K Feb  1 06:45 catalina.out

-rw-r--r--   1 root     root         14M Feb  1 07:00 catalina_backup.out


2.)    The below is heavy logging behavior

# ls -ltrh catalina*

-rw-r-----   1 ems      ems         4.2K Jan 28 22:14 catalina.2012-01-28.log à why I am seeing catalina file with date, have the same content as catalina.out

-rw-r-----   1 ems      ems          362 Jan 30 06:30 catalina.2012-01-30.log

-rw-r-----   1 ems      ems          10M Jan 30 14:43 catalina.out.2

-rw-r--r--   1 root     root        1.7M Jan 30 17:00 catalina_backup.out.9.gz

-rw-r--r--   1 root     root        1.6M Jan 30 20:00 catalina_backup.out.8.gz

-rw-r--r--   1 root     root        1.6M Jan 30 23:00 catalina_backup.out.7.gz

-rw-r--r--   1 root     root        1.6M Jan 31 02:00 catalina_backup.out.6.gz

-rw-r-----   1 ems      ems         113M Jan 31 03:30 catalina.out.3

-rw-r--r--   1 root     root        1.8M Jan 31 06:00 catalina_backup.out.5.gz

-rw-r-----   1 ems      ems         6.2M Jan 31 10:04 catalina.out

-rw-r-----   1 ems      ems         4.5K Jan 31 10:04 catalina.2012-01-31.log

-rw-r--r--   1 root     root        1.8M Jan 31 10:30 catalina_backup.out.4.gz

-rw-r--r--   1 root     root        1.8M Jan 31 15:00 catalina_backup.out.3.gz

-rw-r--r--   1 root     root        1.8M Jan 31 19:30 catalina_backup.out.2.gz

-rw-r--r--   1 root     root        1.8M Feb  1 00:00 catalina_backup.out.1.gz

-rw-r--r--   1 root     root         12M Feb  1 01:00 catalina_backup.out

-rw-r-----   1 ems      ems          12M Feb  1 01:12 catalina.out.1 à why this is latest file ? Is this because of huge logging, Can I disable default catalina.out rotation so that my script will take care of moving the content from catalina.out to catalina_backup.out…




Your urgent reply is appreciated.

asked by akshay_tomcat


The catalina.out file is created by a shell redirection, ex ">> catalina.out 2>&1".  This catches anything written to System.out and System.err and places it into the catalina.out file. 

Given this, a good way to rotate catalina.out is to alter the script to pipe the output to a log rotation script rather than directly to a file.  This will allow you to rotate the logs without restarting Tomcat and without copying the entire contents of the log to another file.

It's a pretty simple change to and it is described at this link.



answered by dmikusa on February 20, 2012 08:27 AM

Daniel Mikusa is a Software Support Engineer at Pivotal.  Daniel has been a user of Apache Tomcat for the past six years and is currently focused on providing enterprise-class support for Pivotal's Tomcat and tc Server customers. Daniel attended college at Kent State University and holds a bachelor's degree in Computer Science.


tomcat stops writing to catalina.out, why?

I have a UI web application. Whenever I have gone a few days without restarting the gui, tomcat stops logging to catalina.out. In fact not only does it stop logging, it empties whatever log output exists in catalina.out, catalina.out.1 and catalina.out.2. If the gui is restarted tomcat will begin logging again.

Steps to Reproduce:
1. Let the web ui run on for a few days without restarting the system or the gui. The UI's server component writes to the log.
2. After a couple of day tomcat stops logging to catalina.out. All three files (catalina.out, catalina.out.1 and catalina.out.2) will be empty.

Any help or hint as why this is happening is appreciated beyond words can express.

Post new comment

This question is for testing whether you are a human visitor and to prevent automated spam submissions.