We use a Log4jConfigListener from the Spring framework, with the following configuration in our web.xml. We use Maven to replace the
variable with a specific folder when we’re packaging the WAR. Note that this gives us hot redeployment of the Log4J configuration, which is really great for development. Even if you don’t use Spring, you might be able to get some ideas from the source code.
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>file:${log4j.config.folder}/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>10000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
From: jetty-users-bounces@xxxxxxxxxxx
[mailto:jetty-users-bounces@xxxxxxxxxxx] On Behalf Of
Algirdas Veitas
Sent: Wednesday, March 23, 2011 10:51 AM
To: jetty-users@xxxxxxxxxxx
Subject: [jetty-users] Separate log4j configuration file for each deployed webapp...
Hi,
Am looking for some guidance on how to configure a separate log4j.properties file for each war that we deploy in our container.
The big restriction here is that we cannot bundle the log4j.properties file in each war, it has to be external to the war itself.
We obviously have been able to configure all wars to use a common log4j.properties through known configuration of Jetty, but have not been successful to configure one per war file.
Appreciate any guidance or past experiences with such a situation.
Thanks in advance....
Al