How to forward Apache Tomcat® logs to logFaces?

Apache Tomcat® is very popular and powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations. Since it's essentially a Java application server, it is very easy to integrate it with logFaces for aggregation its internal logs. Please note that here we describe how to make the application server itself to use logFaces, not the individual applications it hosts which is a similar process but not identical.

What needs to be done is to instruct Tomcat to use log4j2 instead of its default logging framework. We will modify the bootstrap variables and add the required binaries and configuration. The following transcript was tested with Tomcat v9 but can probably be applied to earlier or later versions as well. (Many thanks to Fekade for sharing this).

1. Create the following directories for configuration and binaries:

  • $CATALINA_HOME/log4j2/conf
  • $CATALINA_HOME/log4j2/lib

2. Download log4j2 dependencies and place them under $CATALINA_HOME/log4j2/lib:

  • log4j-api-2.17.1.jar
  • log4j-core-2.17.1.jar
  • log4j-appserver-2.17.1.jar
  • log4j-jul-2.17.1.jar
  • lfsappenders-5.1.0.jar

3. Download the latest logFaces Java appender and place the jar under $CATALINA_HOME/log4j2/lib

4. Create a config file in $CATALINA_HOME/log4j2/conf called log4j2-tomcat.xml and place the following content in it. This is a standard log4j2 configuration with logFaces appender or anything else you'd want to put there. Adjust parameters for your environment.

5. Edit or create $CATALINA_HOME/bin/ (or bat) file and add the following content for Linux or for Windows.

6. Rename or remove $CATALINA_HOME/conf/ Note that you may want to re-apply some of these settings in log4j2 configuration added in (4) because it essentially replaces the Tomcat internal logging.

7. start Tomcat