Reloading Log4j Configuration in Tomcat
When you’re in production environment and you want to diagnose some problems, it’s often handy to have some more logging available. So, when you’re using Log4j, and you want to have your log4j.xml reloaded, you can use Log4jWebConfigurer to make this happen.
To use it, you need to add a listener your web.xml. Be careful to place this before the ContextLoaderListener entry. Also important is to add a log4jRefreshInterval (in milliseconds), else Log4j won’t start it’s deamon thread.
web.xml
<context-param> <param-name>log4jConfigLocation <param-value>classpath:log4j.xml </context-param> <context-param> <param-name>log4jRefreshInterval <param-value>1000 </context-param> <context-param> <param-name>contextConfigLocation <param-value>classpath:/application-context.xml </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener>
This should reload your log4j.xml changes whenever they occur.

Recent Comments