David Johle wrote:
Well I managed to accomplish my goal 100% with the help of some new
features in Log4j 2.x (currently beta-3).
My eventual setup was to use the BasicContextSelector to ensure only a
single logging heirarchy was created for the whole VM regardless of
webapps. Then I tag events per-webapp using a ServletFilter to
manipulate the ThreadContext, and send them all through a central
RoutingAppender which in turn directs the entries (based on the tag) to
the appropriate FileAppender.
Since the tagging is done at the request level, both webapp specific
classes, central libraries, and even VM-wide singletons used by a
request all carry that tag (it uses ThreadLocal internally) and thus get
routed properly.
As for the remaining System.out calls in JSP files, separate Loggers are
defined for those to capture the events created by swallowOutput (which
don't carry the tag) and manually route them the appropriate
FileAppender. Eventually that extra fluff can go away though.
Another nice part about this is I only have a single instance of the
logj4 libraries & a single centralized configuration file, which is A
Good Thing(tm) for this setup.
Lots of other features in log4j2 that I was able to benefit from as well
like dynamic reconfiguration and such, so I also set up my internal
Tomcat logging (read: anything without a tag) to route into Tomcat's
log. Sorry JULI, you just weren't good enough for me ;)
I am not sure that I understand everything here (Tomcat logging has long been quite a
puzzle for me), but I seem to perceive the hope of seeing a long-time dream come true, as
a sysadmin with limited Tomcat/Java/Juli/log4j knowledge : setting up *one* logging
configuration that will just swallow everything from Tomcat and webapps - no matter how
sneaky - into preferably one logfile to start with, with a sensible rotation. And /then/
start refining, as needed.
If so, many thanks.
Would you care to enter the setup instructions in a WiKi article ? I'm willing to be the
test pigeon with a couple of running Tomcats, own webapps, foreign webapps etc.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org