Jira Log Rotation

Brandon Pal August 7, 2014

How does JIRA log rotation work? I can see our logs in /install directory/jira/logs are beign rolled over once a day but I want to also compress an donly keep so many. There is nothign in /etc/logrotate.d for JIRA logs so I'm not sure where/what is doing it.

Any ideas?

3 answers

1 accepted

2 votes
Answer accepted
Brandon Pal August 17, 2014

I've created a cron to auto delte any logs older then 30 days.

30 2 * * * find /opt/atlassian/jira/logs/*.* -mtime +30 | xargs rm

6 votes
Stephen Gurnick
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.
August 8, 2014

Hi Brandon,

I've been investigating this same issue as well.

The logs in JIRA's Installation directory are the Tomcat log files, which are not rotated/expired automatically.

The logs in JIRA's Home directory are the Atlassian log files, which are rotated at around 20MB.

My catalina.out log file (in the Installation log directory) at one point was up to 8GB in size. Other log files here weren't as large but dated back years.

Following these links:

I was able to come-up with a log rotation/expiration solution that works:

(Note: The path to your installation directory and log4j.properties may be different than mine)

  1. I edited the <tt>/usr/local/atlassian/jira/atlassian-jira/WEB-INF/classes/log4j.properties</tt> file and removed console logging from the various logging categories:
    sed -i 's/, console,/,/g' log4j.properties
  2. This got rid of the majority of logging from <tt>/usr/local/atlassian/jira/logs/catalina.out</tt>
  3. But there is still some logging when tomcat processes start in catalina.out so I need to rotate/expire this log file. We can use logrotate for this - here is the config I used in /etc/logrotate.d/atlassian:
    /usr/local/atlassian/jira/logs/catalina.out {
    	copytruncate
    	dateext
    	monthly
    	rotate 6
    	compress
    	delaycompress
    	missingok
    }
  4. I'm not sure if you're using Confluence as well. If so, you'll want to set-up log rotation for its catalina.out file as well. I didn't have to modify its log4j.properties file to remove console logging though.
  5. Next you'll want to come up with a scheme for expiring all of the other Tomcat log files. I wrote a script for that runs as a cron job nightly that removes files after they reach an age of my choosing. I'm happy to provide my script to you if you necessary.

Hope this helps get you going in the right direction. Le me know if you have questions.

-- Stephen

Padmasree P November 2, 2018

Hi Stephen,

I am trying to setup log rotation , request you to share your script which removes file.

Stephen Gurnick
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.
December 10, 2018

Here is the link to the script I use for Atlassian log rotation:

https://github.com/UCLALibrary/atlassian_scripts/blob/master/atlassian_rotate_tomcat_logs

2 votes
Pedro Souza
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 7, 2014

Hey Brandon.

I don't think it's possible to compress the logs automatically, without using a third-party script or tools.

I would like to send you some pages that may give you a better idea, on how the logging works:

https://confluence.atlassian.com/display/JIRA/Logging+and+Profiling

https://confluence.atlassian.com/display/JIRAKB/How+to+Rotate+Catalina+Log+File

https://jira.atlassian.com/browse/JRA-8841

https://jira.atlassian.com/browse/JRA-28941

Please, see this another question regarding auto compress the rotated logs:

https://answers.atlassian.com/questions/235136/can-i-configure-jira-confluence-to-compress-their-rotated-logs

I hope it helps.

Cheers,

Pedro Souza.

Suggest an answer

Log in or Sign up to answer