3
votes

I'm dealing with 2 WAR applications (let's call them app1.war and app2.war) deployed in a tomcat7 environment. Through the setenv.sh I'm extending the classpath to a shared folder located in /opt/configurations.

I'd like to structure my configurations this way: configurations/ ├── app1.properties ├── app2.properties ├── logback-app1.xml └── logback-app2.xml

How do I tell to each application to read different logback*.xml files from the shared classpath? In other words, how do I tell app1.war to read only logback-app1.xml and app2.war to read only logback-app2.xml.

1

1 Answers

0
votes

There is an answer to this question here : http://vtanase.blogspot.com/2012/07/how-to-create-different-logback.html

The point is to use a different JNDI entry declared in each web.xml

<env-entry>
  <env-entry-name>logback/configuration-resource</env-entry-name>
  <env-entry-type>java.lang.String</env-entry-type>
  <env-entry-value>app1/logback.xml</env-entry-value>
</env-entry>

and add a property for logback to look JNDI :

JAVA_OPTS="$JAVA_OPTS -Dlogback.ContextSelector=JNDI"

If the problem was to separate the resulting logging file for each war, there is an other way to achieve this with one single logback.xml using SiftingAppender. Examples can be found :