
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