Bug 1701249

Summary: tomcat doesn't clean own logs by logrotate
Product: Red Hat Enterprise Linux 7 Reporter: Markus Schibli <mschibli>
Component: tomcatAssignee: Coty Sutherland <csutherl>
Status: CLOSED WONTFIX QA Contact: tomcat-qe
Severity: medium Docs Contact:
Priority: medium    
Version: 7.6CC: cww
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-04 21:00:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1722607    
Attachments:
Description Flags
Output of the /var/log/tomcat directory none

Description Markus Schibli 2019-04-18 13:45:26 UTC
Created attachment 1556136 [details]
Output of the /var/log/tomcat directory

Description of problem:
I look at system where the tomcat has run for long time. And a lot of old log files exist, I suppose that the logs should be cleaned.

>> ls  /var/log/tomcat/

total 931192    <<<<<<<<<<<<<see the high amount of files (!)
-rw-r--r-- 1 tomcat tomcat     18938 Sep 28  2016 catalina.2016-09-28.log
-rw-r--r-- 1 tomcat tomcat     28648 Sep 29  2016 catalina.2016-09-29.log
-rw-r--r-- 1 tomcat tomcat      9461 Sep 30  2016 catalina.2016-09-30.log
-rw-r--r-- 1 tomcat tomcat      9675 Oct  1  2016 catalina.2016-10-01.log
-rw-r--r-- 1 tomcat tomcat      9925 Oct  3  2016 catalina.2016-10-03.log
-rw-r--r-- 1 tomcat tomcat      9478 Oct  4  2016 catalina.2016-10-04.log
-rw-r--r-- 1 tomcat tomcat     67972 Oct  5  2016 catalina.2016-10-05.log
-rw-r--r-- 1 tomcat tomcat      9670 Oct  6  2016 catalina.2016-10-06.log
-rw-r--r-- 1 tomcat tomcat      9674 Oct  7  2016 catalina.2016-10-07.log
-rw-r--r-- 1 tomcat tomcat      9674 Oct  8  2016 catalina.2016-10-08.log
-rw-r--r-- 1 tomcat tomcat      9674 Oct  9  2016 catalina.2016-10-09.log
-rw-r--r-- 1 tomcat tomcat      9727 Oct 10  2016 catalina.2016-10-10.log
-rw-r--r-- 1 tomcat tomcat      9477 Oct 11  2016 catalina.2016-10-11.log
-rw-r--r-- 1 tomcat tomcat      9674 Oct 12  2016 catalina.2016-10-12.log
-rw-r--r-- 1 tomcat tomcat      9675 Oct 13  2016 catalina.2016-10-13.log
-rw-r--r-- 1 tomcat tomcat       250 Oct 17  2016 catalina.2016-10-17.log
-rw-r--r-- 1 tomcat tomcat       250 Oct 24  2016 catalina.2016-10-24.log
-rw-r--r-- 1 tomcat tomcat       250 Oct 31  2016 catalina.2016-10-31.log
-rw-r--r-- 1 tomcat tomcat     59532 Nov  1  2016 catalina.2016-11-01.log
-rw-r--r-- 1 tomcat tomcat     28430 Nov  4  2016 catalina.2016-11-04.log
-rw-r--r-- 1 tomcat tomcat       250 Nov  7  2016 catalina.2016-11-07.log
-rw-r--r-- 1 tomcat tomcat       250 Nov 14  2016 catalina.2016-11-14.log
-rw-r--r-- 1 tomcat tomcat    237373 Nov 17  2016 catalina.2016-11-17.log
-rw-r--r-- 1 tomcat tomcat       250 Nov 21  2016 catalina.2016-11-21.log
-rw-r--r-- 1 tomcat tomcat       250 Nov 28  2016 catalina.2016-11-28.log
-rw-r--r-- 1 tomcat tomcat     34337 Nov 29  2016 catalina.2016-11-29.log
-rw-r--r-- 1 tomcat tomcat     34003 Nov 30  2016 catalina.2016-11-30.log
-rw-r--r-- 1 tomcat tomcat     61087 Dec  1  2016 catalina.2016-12-01.log
-rw-r--r-- 1 tomcat tomcat     68240 Dec  2  2016 catalina.2016-12-02.log
-rw-r--r-- 1 tomcat tomcat     34581 Dec  3  2016 catalina.2016-12-03.log
-rw-r--r-- 1 tomcat tomcat     30584 Dec  4  2016 catalina.2016-12-04.log
-rw-r--r-- 1 tomcat tomcat     32703 Dec  5  2016 catalina.2016-12-05.log
-rw-r--r-- 1 tomcat tomcat     35446 Dec  6  2016 catalina.2016-12-06.log
-rw-r--r-- 1 tomcat tomcat     35461 Dec  7  2016 catalina.2016-12-07.log
-rw-r--r-- 1 tomcat tomcat     35162 Dec  8  2016 catalina.2016-12-08.log
-rw-r--r-- 1 tomcat tomcat     79718 Dec  9  2016 catalina.2016-12-09.log
-rw-r--r-- 1 tomcat tomcat     35161 Dec 10  2016 catalina.2016-12-10.log
-rw-r--r-- 1 tomcat tomcat     31463 Dec 11  2016 catalina.2016-12-11.log
-rw-r--r-- 1 tomcat tomcat     33837 Dec 12  2016 catalina.2016-12-12.log
-rw-r--r-- 1 tomcat tomcat     34005 Dec 13  2016 catalina.2016-12-13.log
.
snip
.
-rw-r--r-- 1 tomcat tomcat         0 Mar  1 20:10 manager.2019-03-01.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  2 20:11 manager.2019-03-02.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  3 20:11 manager.2019-03-03.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  4 20:10 manager.2019-03-04.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  5 20:11 manager.2019-03-05.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  6 07:32 manager.2019-03-06.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  7 20:09 manager.2019-03-07.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  8 20:11 manager.2019-03-08.log
-rw-r--r-- 1 tomcat tomcat         0 Mar  9 20:09 manager.2019-03-09.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 10 20:10 manager.2019-03-10.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 11 20:11 manager.2019-03-11.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 12 20:10 manager.2019-03-12.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 13 20:10 manager.2019-03-13.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 14 13:46 manager.2019-03-14.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 15 20:10 manager.2019-03-15.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 16 20:10 manager.2019-03-16.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 17 20:11 manager.2019-03-17.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 18 20:12 manager.2019-03-18.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 19 20:12 manager.2019-03-19.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 20 20:11 manager.2019-03-20.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 21 20:10 manager.2019-03-21.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 22 20:11 manager.2019-03-22.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 23 20:09 manager.2019-03-23.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 24 20:11 manager.2019-03-24.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 25 20:11 manager.2019-03-25.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 26 20:12 manager.2019-03-26.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 27 20:12 manager.2019-03-27.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 28 10:19 manager.2019-03-28.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 29 20:11 manager.2019-03-29.log
-rw-r--r-- 1 tomcat tomcat         0 Mar 31 20:12 manager.2019-03-31.log
-rw-r--r-- 1 tomcat tomcat         0 Apr  1 07:11 manager.2019-04-01.log
-rw-r--r-- 1 tomcat tomcat         0 Apr  2 09:30 manager.2019-04-02.log
-rw-r--r-- 1 tomcat tomcat         0 Apr  3 14:26 manager.2019-04-03.log
-rw-r--r-- 1 tomcat tomcat         0 Apr  4 07:30 manager.2019-04-04.log

$ cat etc/logrotate.d/tomcat 
/var/log/tomcat/catalina.out {
    copytruncate
    weekly
    rotate 52
    compress
    missingok
    create 0644 tomcat tomcat
}


Version-Release number of selected component (if applicable):

$ cat etc/redhat-release 
Red Hat Enterprise Linux Server release 7.6 (Maipo)

$ grep -i tomcat installed-rpms 
lh555.server.raiffeisen.ch-tomcat-1.0-1.noarch              Tue Feb 13 07:04:46 2018
tomcat-7.0.76-8.el7_5.noarch                                Wed Nov 14 09:19:38 2018
tomcat-el-2.2-api-7.0.76-8.el7_5.noarch                     Wed Nov 14 09:18:39 2018
tomcat-jsp-2.2-api-7.0.76-8.el7_5.noarch                    Wed Nov 14 09:18:05 2018
tomcat-lib-7.0.76-8.el7_5.noarch                            Wed Nov 14 09:18:40 2018
tomcat-servlet-3.0-api-7.0.76-8.el7_5.noarch                Wed Nov 14 09:18:04 2018


How reproducible:
alawys

Steps to Reproduce:
1. run tomcat long time
2. show content of directory with logs 


Actual results:
A lot of logs files

Expected results:
old log files was compressed or remove


Additional info:

The same bug was opened for rhel 6.9 but was closed as WONTFIX due to "Red Hat Enterprise Linux 6 is in the Production 3 Phase."

Comment 2 Markus Schibli 2019-04-18 13:47:20 UTC
mentioned closed BZ was https://bugzilla.redhat.com/show_bug.cgi?id=1451314

Comment 3 Coty Sutherland 2019-04-18 15:33:56 UTC
I provided a patch suggestion on the rhel-6 issue, https://bugzilla.redhat.com/show_bug.cgi?id=1451314#c2. I'm not sure if it's feasible or not (it never got reviewed), but I'll look into it for rhel-7.

Comment 4 Coty Sutherland 2020-03-04 21:00:33 UTC
The proposed solution from rhbz#1451314 was to add *.log to the logrotate configuration:

~~~
/var/log/tomcat/catalina.out 
/var/log/tomcat/*.log
{
    copytruncate
    weekly
    rotate 52
    compress
    missingok
    create 0644 tomcat tomcat
}
~~~

Users are free to go that route, however it will likely interfere with tomcat's ability to rotate it's own logs. The better solution to the problem of having too many logs after long periods of time is to utilize the o.a.juli.FileHandler's maxDays attribute (see https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/juli/FileHandler.html) to limit the number of logs kept. By default it keeps them forever, which is why there are a lot of long files after several days. If users want to use logrotate instead, then they should set the rotatable attribute of the FileHandler to false rather than true which will prevent tomcat from rotating it's own logs and allow the file management to fall to logrotate.

Comment 5 RHEL Program Management 2020-03-04 21:00:41 UTC
Development Management has reviewed and declined this request. You may appeal this decision by using your Red Hat support channels, who will make certain  the issue receives the proper prioritization with product and development management.

https://www.redhat.com/support/process/production/#howto