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.
- 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
server.xml
andÂsetenv.sh
! If your have customised these, see the detailed instructions in the same README and ensure your have the correctValve
element for access logging. - Make sureÂ
$CATALINA_HOME/conf/logging.properties
is deleted. - Adjust
$CATALINA_HOME/conf
and/logback.xml
$CATALINA_HOME/conf
to your logging needs./logback-access.xml
- Start Tomcat with
$CATALINA_HOME/bin/startup.sh
and enjoy Logback!