[logback-user] separate configs for each web app and tomcat

Ceki Gulcu ceki at qos.ch
Thu Jul 17 16:57:11 CEST 2008


Hello Lucas,

Many thanks for this post. I wish we had a wiki to keep track of this kind of 
contributions.

Cheers,

Lucas, Casey wrote:
> Since there has been some recent discussion of tomcat, slf4j,
> jcl-over-slf4j and logback combinations, this account of how
> we solved our problem may be useful to some.... or maybe
> someone has a better way.
> 
> Our desires:
> 
> - use a standard (within our organization) java logging
> implementation
> 
> - have logging for each application be separately configurable
> but share a common syntax (so we wouldn't have to remember
> all different configuration details)
> 
> - use the same logging implementation for tomcat
> 
> - support existing applications that send throttled email
> alerts (log4j based)
> 
> - we had some other desires but the above are important for
> this discussion
> 
> Our solution:
> 
> We used logback, slf4j, log4j-over-slf4j, and jcl-over-slf4j
> in combination with a custom logback context selector.
> 
> More details:
> 
> We ran into similar problems as others have mentioned.  Once
> we included jcl-over-slf4j in tomcat, we had initialization
> problems.  We tried the JNDI context selector but it didn't
> work.  Basically, as tomcat is loading a web app, it attempts
> some logging (using jcl) before it sets up the jndi context.
> As soon as the first logging statement is run, logback will
> be initialized.  Since it cant use any jndi information,
> it uses the default initialization process.  This default
> initialization process is not very useful when you want to
> have a per application (and tomcat) logback configuration.
> 
> We ended up writing a logback context loader that loads
> it's configuration based on classpath resources.  Then we
> placed tomcat specific files in tomcat/server/lib and
> tomcat/server/classes (vs. tomcat/common).  By placing in
> tomcat/server, web apps can't see the tomcat specific
> configs and jars.  Each web application then placed it's
> logging jars and configuration files in their own WEB-INF.
> Benefits of this configuration:
> 
> - tomcat and each web app can have their own logging
> configuration
> 
> - each logback context can be managed separately via JMX
> 
> 
> Hope this helps someone.
> 
> -casey
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
> 

-- 
Ceki Gülcü

QOS.ch is looking to hire talented developers located in Switzerland
to work on cutting-edge software projects. If you think you are
qualified, then please contact ceki at qos.ch.



More information about the Logback-user mailing list