File "catalina.out" not being created/populated when using Tomcat 9.0.31 + Ubuntu 20.04, and content goes to the Ubuntu syslog instead

Bug #1884591 reported by Brian Braun on 2020-06-22
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tomcat9 (Ubuntu)

Bug Description


I have been using Tomcat for about 18 years (several versions). As far as I can remember, everything that I leave on the log with System.out.println() has been found inside the file "catalina.out", which has been nice. However, this seems to have changed.

I just migrated to Ubuntu 20.04 LTS + Tomcat 9.0.31, and installed Tomcat doing a "sudo apt install tomcat9". Now I see that the file "catalina.out" never gets created, and that everything that had been sent there is now being sent to the Ubuntu/Linux/Debian log "syslog". I don't like that, I want to keep having a separate/dedicated log for Tomcat (which is something I check very often) and not havoing to search for it inside syslog (which is something I rarely inspect). I think this is a bug.

I have done some research, and this is what I have discovered (if I understood everything correctly):

- Tomcat now runs as a service inside something called "systemsd"
- For some reason, the people at Ubuntu/Debian/Linux decided that Tomcat's log should be found inside syslog, instead of staying independent inside "catalina.out". Why is that? I don't know and it doesn't make sense.
- The other files inside /var/log/tomcat get created, including the "catalina.YYYY-MM-DD.log" files. But I dont' find my "System.out.println()" messages there, which has always been the case.
- I have found, however, that syslog tries to create and populate the "catalina.out" file as well, since I have found an error inside syslog that says something like "rsyslogd: file '/var/log/tomcat9/catalina.out': open error: Permission denied".
- I have also found a file "/etc/rsyslog.d/tomcat9.conf" which, indeed, seams to indicate syslog that the file "/var/log/tomcat9/catalina.out" must be populated. Which makes sense and should solve my needs.
- Considering the "Permission denied" error message, I started playing with the permissions (something that I really don't have much experience with). If I remember correctly, I created the file "catalina.out" manually, and the modified its properties so the owners are "tomcat/adm", since the "syslog" process/user seems to be inside the "adm" group. Restarted everything... and the "catalina.out" file got created and populated!!! So it seems that the main obstacle here is a lack of correct permissions so syslog can do what has been told and populate the "catalina.out" file. Did I get it right?
- However, when I delete all the log files (which I do every once in a while), the permissions that I assigned get lost and the file doesn't get created anymore. In addition, when I restart Ubuntu the permissions that I set get lost.

What are we supposed to do to deal with this problem? Can/should we do something so the Tomcat log doesn't go to syslog? If not, and considering that it seems that syslog is trying to populate the "catalina.out" file as it has been told, what should we do to correct the permissions problem to solve this bug?

Thanks in advance!

Emmanuel Bourg (ebourg) wrote :

The /var/log/tomcat9/catalina.out file is written by rsyslogd, in Debian rsyslogd runs as root so the permissions do not matter, but in Ubuntu rsyslogd runs as syslog:adm and it only has read permissions in /var/log/tomcat9/.

The tomcat9 package should be patched to change the permissions set by systemd-tmpfiles in /usr/lib/tmpfiles.d/tomcat9.conf (chmod 2750 -> 2760).

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers