Apache Tomcat and Logging – The 2nd

By | June 26, 2012

After I got the access logs for our Tomcat‘s to syslogd (see the entry below), I found that the Solaris syslogd can not handle the the RFC-5424 header format:-( So the info in that section was not really useful for us.

That brought up a new problem, I needed to include the process ID in the log records. So I updated my little extension jar to handle an extra %P format specifier for the SyslogAccessLogValve class.

The normal log4j 1.2 also has no real way to include the process ID in the records. So I added a little org.apache.log4j.PidPatternLayout which handles the %P in addition to the normal PatternLayout.

The new jar file with both the sources and all the classes is here;-) mw2.jar

I hope it helps some people. Have fun playing,
— Marco

Update:  Here is a new version of the jar: mw3.jar which hopefully removes the StringManager dependency for Tomcat7. I still did not test it with Tomcat7!!

Update: Next post in what becomes a series?!

11 thoughts on “Apache Tomcat and Logging – The 2nd

  1. magwas

    Many thanks, however on tomcat7 I get java.lang.NoClassDefFoundError: org/apache/catalina/util/StringManager for both versions of your jar
    Jarfinder says the class is in catalina.jar, for versions <= tomcat 6, and gwt-dev (??)
    I would try to leave out the sm field, but not yet pulled out my eclipse.

  2. admin Post author

    That’s fine;-) I’m happy that it works for you. Have fun.

  3. Pingback: Apache Tomcat Access Log to Syslogd - Marco's Corner

  4. Pingback: Apache Tomcat and Logging – The 3rd - Marco's Corner

  5. Christopher Murchison

    Thanks for this it has been a great help. Any plans for a Tomcat 8 compatible version? Just wondering (I know it has been a few years now but i thought i`d ask anyway).

  6. admin Post author

    I don’t use Tomcats right now. So not really, sorry.

  7. Peter

    Hi, thanks for Your great works, it has been very helpful for our logging infrastructure.

    However, we use Tomcat 8 now, and we’ve forked in our repository here:
    https://github.com/KMK-ONLINE/SyslogValve.git which is supposed to work for Tomcat 8.

    Some performance adjustment to this first modification is still required, though.

  8. admin Post author

    OK, I forked your code and made some changes again. I should have put it into a github repo a long time ago. But originally, this was a quick hack and I thought, I’m done. But it’s coming back all the time;-)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.