The method which is given in all forum is this.

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/resources/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigList ener
</listener-class>
</listener>

But on using this I get an error that the war must be unpacked to use this. For some reasons I want to deploy a packed war only on tomcat.

The solution which I read somewhere was to use following

<bean id="log4jInitialization"
class=
"org.springframework.beans.factory.config.MethodIn vokingFactoryBean">
<property name="targetClass"
value="org.springframework.util.Log4jConfigurer" />
<property name="targetMethod" value="initLogging" />
<property name="arguments">
<list>
<value>classpath:conf/log4j.xml</value>
</list>
</property>
</bean>

But this gives a warning:

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.

The error is probably due to listener class org.springframework.web.context.ContextLoaderListe ner being called earlier than log4j listener.

How do I get round this problem.