Apache Tomcat logging with Logback

This page describes how to replace Apache Tomcat's internal and access logging with SLF4J and Logback. It is entirely based on the project "Tomcat + SLF4J + Logback" by Grzegorz Grzybek which provides releases for various Tomcat versions. Using this project does not interfere with web applications that provide their own logging framework because only classes under org.apache.juli.logging are replaced, nor will it prevent web applications from using the old java.util.logging. However, it probably does not go along well with Tomcat installed from packages provided by Linux distributions because at least one of Tomcat-provided libraries is replaced. Installing Tomcat from Apache's binary distribution is therefore recommended.

  1. Install Apache Tomcat from https://tomcat.apache.org/.
  2. Download the tomcat-slf4j-logback release matching Tomcat's version.
  3. Follow the quick start instructions in tomcat-slf4j-logback/README. This will overwrite Tomcat's server.xml and setenv.sh! If your have customised these, see the detailed instructions in the same README and ensure your have the correct Valve element for access logging.
  4. Make sure $CATALINA_HOME/conf/logging.properties is deleted.
  5. Adjust $CATALINA_HOME/conf/logback.xml and $CATALINA_HOME/conf/logback-access.xml to your logging needs.
  6. Start Tomcat with $CATALINA_HOME/bin/startup.sh and enjoy Logback!