[logback-user] Logback with Tomcat and multiple web applications

Robert Elliot rob at lidalia.org.uk
Wed Feb 11 18:04:54 CET 2009


Use a ServletContextListener to put the application name into the MDC (servletContext.getServletContextName()) when the app starts.  Then you can configure filters to allow you to log different application to different places, and you can use the MDC in the log output.

As a general rule a web app that isn't part of an EAR should be deployed on a standalone basis, so you shouldn't really be deploying your jars & config to Tomcat/lib - that's outside the servlet specification.  I know it seems a little wasteful to have the same jars in every web-inf/lib directory, but it's not really taking up much space.

----- Original Message -----
From: "Ryan Cornia" <rcornia at myriad.com>
To: logback-user at qos.ch
Sent: Wednesday, 11 February, 2009 16:57:17 GMT +00:00 GMT Britain, Ireland, Portugal
Subject: [logback-user] Logback with Tomcat and multiple web applications

I've been struggling with this in Log4J, and am wondering if it's possible
in Logback.

If I have tomcat, with several web applications, can I have one instance of
the logback jars in Tomcat/lib, and one configuration file, but distinguish
between applications via variable substitution and the pattern?

We are logging to SYSLOG, so I would like the pattern to include the
application name. 

I looked through the manual, and see you can use variable substitution for
specifying different files, but does substitution work in the pattern field?
Can the ContextJNDISelector use a configuration file outside of the war?
Ideally I would have the logging configuration file in tomcat/conf or
somewhere, and have all applications use the same one.

Thanks for any help!





_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list