Spring’s Log4JWebConfigurer October 12, 2007Posted by Phill in Spring.
Tags: log4j configuration, log4jwebconfigurer, Spring
In the JavaDoc for Spring’s Log4JWebConfigurer, there’s a bold “warning”, letting you know that it “Assumes an expanded WAR file”. If you want to use an unexpanded WAR file, the advice is to use a VM-wide Log4J setup.
Unfortunately, in our case we needed to have our application use a particular Log4J properties file, and we needed it to be outside the WAR file (i.e. in a shared properties folder on the server). The shared properties folder is on the classpath – so it is available to the application – but unfortunately our EAR file is unexpanded.
In the end, we managed to get it to work: in
web.xml, you can add a “classpath:” attribue to the
log4jConfigLocation attribute. You also need to set the
log4jExposeWebAppRoot property, otherwise (on WebLogic at least) the deployment will fail with an error about setting the WebApp home for an unexpanded EAR file.