Hi Perry,
My use case is basically the same as yours, except im deploying wars in
a tomcat and not in a full jboss et al.
The solution, i came up with is based on logbacks ability to look up
values in a JNDI directory and to include files based. Basically you
pack a skeleton logback configuration with your war. This skeleton
configuration file simply looks up the url for a file containing the
real configuration using JNDI and then includes it.
I have attached 3 files, i use to do all this magic, in one of my
projects as an example.
logback.xml is the skeleton configuration file, which goes into the war.
It contains a maven pom.name reference, since i use maven filtering to
ensure, the lookup key matches application. I tend to forget updating
things like that when reusing code etc.
context.xml is a sample context, i use when testing this particular
webapp in an embedded tomcat. I have no parameters defined in web.xml,
since i dont want to risk silently falling back to defaults, i prefer to
go out with a bang.
logback-test.xml is the actual logback configuration to be included. I
know, its a bad choice of name, since its a logback magic file name.
I discussed the solution with Ceki on this list under the subject
'configuration through JNDI' and got the seal of approval, and it has
worked for me without any problems so far.
Yours sincerely,
Bjorn
<!-- $Id: -->
<configuration scan="true" scanPeriod="5 minutes">
<insertFromJNDI env-entry-name="java:comp/env/${pom.name}/logback" as="logbackConfiguration"/>
<include url="${logbackConfiguration}"/>
</configuration>
<!-- $Id: -->
<Context>
<Environment name="holdings/logback" value="file://${catalina.base}/../../target/tomcat/conf/logback-test.xml"
type="java.lang.String" override="false"/>
<Environment name="holdings/configuration"
value="file://${catalina.base}/../../target/tomcat/conf/holdings.properties"
type="java.lang.String"
override="false"/>
</Context>
<!-- $Id: -->
<included>
<contextName>holdings</contextName>
<appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${catalina.home}/logs/${CONTEXT_NAME}.log</File>
<encoder>
<pattern>%d [%t] %-5p %c - %m%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>10</maxIndex>
<FileNamePattern>${catalina.home}/logs/${CONTEXT_NAME}.log.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>32MB</MaxFileSize>
</triggeringPolicy>
</appender>
<root level="info">
<appender-ref ref="R"/>
</root>
</included>
_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user