[logback-user] Externalized Logback configuration for web applications

Larry J ljacobson at entertainmentpartners.com
Mon Sep 24 22:55:08 CEST 2012


Thank you for the simple recipe using logback.xml.  Is there an equally
simple way using the groovy configuration?

If I try embedding these lines into logback.groovy:
       shell = new GroovyShell(binding)
       shell.evaluate(new File("/etc/logback-override.groovy").text)
I get missing property exceptions when I try to use the 'root' and 'logger'
methods from the external file.

Any help appreciated!



Ceki Gulcu wrote:
> 
> On 17.08.2012 06:23, Perryn Fowler wrote:
>> Hello,
>>
>> I have a logging use case that I would think was relatively common,
>> but that does not seem to be supported particularly well by logback.
>> I wanted to see what the logback community thinks/advises.
>>
>> The details of the use case
>> - I am writing java web apps to be deployed to JEE web containers.
>> - I want the logging config to be external to the wars, so that I can
>> use the same wars in different environments, but configure logging
>> differently.
>> - I want to be able to deploy several different wars to the same web
>> container and have them use different logging configurations.
> 
> Here is a simple recipe:
> 
> 1) Package logback jars in each web-app separately.
> 2) In web-app A, place a logback.xml file which references an external 
> file for inclusion. Example:
> 
> # --- logback.xml shipping in web-app A -------
> 
> <configuration debug="true">
>    <include file="/opt/logback-A.xml">
> </configuration>
> 
> # ----------------------------------------------
> 
> /opt/logback-A.xml would contains the config specific for web-app A.
> 
> 3) Do the same for your other web-apps.
> 
> 4) Declare victory.
> 
> 
> As Bjorn mention, you can parameterize the reference to the included 
> file via JNDI (or any of the other variable types supported in logback).
> 
> HTH,
> 
> -- 
> Ceki
> http://tinyurl.com/proLogback
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
> 
> 
-- 
View this message in context: http://old.nabble.com/Externalized-Logback-configuration-for-web-applications-tp34310052p34473856.html
Sent from the Logback User mailing list archive at Nabble.com.



More information about the Logback-user mailing list