Tomcat 9 - catalina.out log file missing and console printouts are not shown anywhere

Tomcat9 deployed on Ubuntu 18.04. This issue ONLY applies to Tomcat version 9. There is a catalina.date.log file present in the logs folder but it does NOT show any console printouts from our web applications.

I've set the ConsoleHandler level to ALL in logging.properties, still no logs.

Any pointers, ideas? Thanks!


Solution 1:

The tomcat9 package on Ubuntu 18.04 (and Debian 10) use a systemd .service file. By default they redirect Tomcat's stdout and stderr to syslog with a program name tomcat9. In Debian 10 RSyslog is configured to write those to /var/log/tomcat9/catalina.out, but that might not be true in your case.

So you have at least two solutions:

  1. Read the output from systemd-journald:

    journalctl -u tomcat9.service
    

    You probably want to make journald storage persistent (the solution for CentOS also applies to Ubuntu).

  2. Modify the .service file to redirect output to /var/log/tomcat9/catalina.out

    systemctl edit --full tomcat9.service
    

    and follow the instructions on StackOverflow.

Remark that “logging” through System.out.println and similar is bad practice, since you cannot control what is logged and how. You can use the swallowOutput attribute on the context if you want to send those statements to java.util.logging. All messages logged through ServletContext#log() and java.util.logging end up in either catalina.<date>.log or localhost.<date>.log.