annotate content/Java/log4j-based-logging-in-tomcat-part1.md @ 63:9693693301f2

add blog post on NFS server
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 30 Jul 2015 07:32:04 +0200
parents 4cd9b65e10e4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 Title: Log4j based logging in Tomcat 6
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 Date: 2008-06-14
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 Tags: logging, log4j, Tomcat
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 Lang: en
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 My favourite annoyance in Tomcat is its logging to the ever-growing, never-rotated `catalina.out`.
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8 The [Tomcat logging setup instructions](http://tomcat.apache.org/tomcat-6.0-doc/logging.html) already contain a description what to do to make Tomcat log through log4. This is definitely a step in the right direction. Tomcat's logging is properly separated from each webapp's logging and only output written to `System.out` will end up in catalina.out.
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 For hosting third party jars I originally also wanted a mechanism that caputres `System.out` and `System.err` and pipes it through commons-logging also. This is to avoid that some misbehaving webapp fills up catalina.out again.
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 After a lot of poking around with commons-logging, the package rewritten commons-logging called *Juli* in Tomcat and a simple sample webapp that writes to `System.out` I came to the conclusion that the best you can get is what's described in Tomcat's logging setup.
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13
4cd9b65e10e4 initial import of the pelican based blog
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 Since Tomcat has code in place to redirect `System.out` and `System.err` to `catalina.out`, there is no easy way to do custom commons-logging initialization after Tomcat redirected System.out and System.err.