I am loading log4j.xml using the traditional way
This works fine but now I need to load a different log4j.xml file based on which environment I am in which is defined by a environment variable/jndi entry .. so I was hoping that with new spring 3.1 property management I could just change this toCode:<context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:conf/log4j.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>
and spring will load the correct log4j file in each environment but this doesnt works probably because web.xml is loaded before spring. I came across this methodCode:<context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:conf/log4j-${WASENV}.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>
so essentially moving configuration of log4j into spring context file instead of web.xml. Is there a cleaner way to do this.Code:<!-- log4j setting --> <bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="org.springframework.util.Log4jConfigurer" /> <property name="targetMethod" value="initLogging" /> <property name="arguments"> <list> <value>log4j-${WASENV}.xml</value> </list> </property> </bean>
Any help would be appreciated.
Thanks
Adeel


Reply With Quote