Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: better explanation for logging

...

By default Tomcat logs everything multiple times, including to /var/log/tomcat9/catalina.$date.logout and /var/log/tomcat9/localhost.$date.log, which we don't care for. So let's create a backup copy of Tomcat's logging.properties and replace its content with the minumum needed to get an access log comparable to Apache httpd written to /var/log/tomcat9/access.log. Tomcat's stdout/stderr will go to to the console (which ends up in the systemd journal. There will be no catalina.out to manage). To prevent catalina.out from being created we deacticate it further below (in our "Systemd service" override) by setting the CATALINA_OUT=/dev/null environment variable for the Java process.

No Format
systemctl stop tomcat9
cp -a /etc/tomcat9/logging.properties /etc/tomcat9/logging.properties.`date -u +%Y%m%d`
 
echo -n 'handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = org.apache.juli.SystemdFormatter
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.ConsoleHandler
' > /etc/tomcat9/logging.properties

...