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.
- Install Apache Tomcat from https://tomcat.apache.org/.
- Download the tomcat-slf4j-logback release matching Tomcat's version.
- Follow the quick start instructions in tomcat-slf4j-logback/README. This will overwrite Tomcat's
setenv.sh! If your have customised these, see the detailed instructions in the same README and ensure your have the correct
Valveelement for access logging.
- Make sure
$CATALINA_HOME/confto your logging needs.
- Start Tomcat with
$CATALINA_HOME/bin/startup.shand enjoy Logback!