You need the following components to begin:

  1. A Tomcat server (I took Apache Tomcat 7, but it should work the same way for Tomcat 5 and 6)
  2. Logstash (currently version 1.4.2)
  3. Logstash-Gelf (currently version 1.4.2)

Having all dependencies allows you to proceed with the integration - hassle-free, multi-lined messages and stack traces are working out of the box.

One word at java util logging

Tomcat uses the java util logging in order to produce log output for the server itself. The log system in the Tomcat server is initialized as one of the first, even before utilizing the library classpath. Therefore you have to have any logging libraries on the JVM's starting class path (java -cp ...). To achieve this, you've got to modify the startup scripts. I've added a full listing and a diff.

Now adjust the Tomcat server

  1. Extract the logstash-gelf module and drop all the jars (commons-pool2-2.0.jar, jedis-2.5.1.jar, json-simple-1.1.jar, logstash-gelf-1.4.2.jar) into the bin-directory of your Tomcat server (or you can use every other path outside the lib-directories. This example relies on the bin-directory)
  2. Add the jars to the Tomcat class path modifying the bin/ or bin/catalina.bat file (see Gist for diff)
    if [ -r "$CATALINA_BASE/bin/logstash-gelf-1.4.2.jar" ] ; then
  3. Add the log handler to conf/ (see Gist for the full file)
    handlers =,,,, java.util.logging.ConsoleHandler, biz.paluch.logging.gelf.jul.GelfLogHandler
    .handlers =, java.util.logging.ConsoleHandler, biz.paluch.logging.gelf.jul.GelfLogHandler

  4. Start Tomcat and enjoy logging!