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!
Best Answer
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 nametomcat9
. 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:
Read the output from
systemd-journald
:You probably want to make journald storage persistent (the solution for CentOS also applies to Ubuntu).
Modify the
.service
file to redirect output to/var/log/tomcat9/catalina.out
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 tojava.util.logging
. All messages logged throughServletContext#log()
and java.util.logging end up in eithercatalina.<date>.log
orlocalhost.<date>.log
.