My never ending story with Tomcat and logging.  The previous posts are here and here. This version has two updates.

  1. Tomcat was still sending the System.out and System.err streams to the shell and eventually to catalina.out in the normal configuration.  The jar file now contains a life cycle listener which can be used to redirect those to syslogd as well.  Just add a line like <Listener className=”org.apache.log4j.contrib.ServerLifecycleListener” /> to the to of the server.xml after all the other <Listener> elements. The new streams will show up as [stderr] and [stdout].
  2. We use JRuby on Rails inside our Tomcat. That setup sticks sometimes many lines including ‘\n’s and terminal color codes into one logging message. The normal  SyslogAppender class will split the message based on the maximum length for syslogd. But that does create messages which are hard to read. So I created a subclass of the, called, which splits any message on ‘\n’ and also cleans up all the terminal codes which just add clutter to the syslogd messages. Just replace the with in your to play with it.

The updated jar with all the sources is mw-syslog.jar. Maybe I’ll create a github repo eventually for this. Every time I hope it’s the last change, but I come back to again and again.

As always, have fun,