How to rotate the Tomcat catalina log file

By default, Confluence applications mirror the application log output (atlassian-confluence.log) to the Tomcat log file, catalina.out. This file can grow quite large and cannot be rotated by JIRA applications using Log4j configuration.

# 1. Check that your system has logrotate installed:
which logrotate

# 2. Purge the contents of catalina.out.
echo > /opt/atlassian/confluence/logs/catalina.out

# 3. Find the user and group that is set for the parent directory:
ls -la /opt/atlassian/confluence/logs

# 4. Create a file at /etc/logrotate.d/confluence-tomcat.conf
/opt/atlassian/confluence/logs/catalina.out {
	rotate 5
	size 20M
	nocompress
	notifempty
	missingok
	copytruncate
	su THE_USER THE_GROUP
}

# 5. Perform a test rotation:
logrotate --force /etc/logrotate.d/confluence-tomcat.conf

# 6. Verify it's working correctly by checking that there are now two files, catalina.out and catalina.out.1:
ls /opt/atlassian/confluence/logs | grep catalina.out

Sliding Sidebar

About Me

About Me

Hello, my name is Dũng (Johnny). Welcome to my blog.

As I’m a developer, I write about topics related to the field of programming, mainly from a technical point of view. On this blog you’ll find posts which encourage discussion, information about development trends, case studies, reviews, tutorials, tips on how to improve your effectiveness, and anything else that might be fascinating to people from the IT industry.
I love PHP, NodeJS, Java,... and Fullstack.