I was using log4j in one of my spring maven projects. although the log4j.xml were well done, I get a warning then an error during deployment :
Initializing Spring root WebApplicationContext
[stderr] (ServerService Thread Pool -- 74) log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
ERROR [stderr] (ServerService Thread Pool -- 74) log4j:WARN Please initialize the log4j system properly.
ERROR [stderr] (ServerService Thread Pool -- 74) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
My log4j.xml was under src/main/resources. bUT EVEN BY SPECIFYING THE log4jConfigLocation, didn't resolve the problem.
So my Web.xml were like this:
After some invetigation, I have found that we should add a Log4jConfigListener in the first line (with the log4jConfigLocation) :
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
So the Web.xml become:
Wasn't easy to find but at least now it is done :)
Initializing Spring root WebApplicationContext
[stderr] (ServerService Thread Pool -- 74) log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
ERROR [stderr] (ServerService Thread Pool -- 74) log4j:WARN Please initialize the log4j system properly.
ERROR [stderr] (ServerService Thread Pool -- 74) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
My log4j.xml was under src/main/resources. bUT EVEN BY SPECIFYING THE log4jConfigLocation, didn't resolve the problem.
So my Web.xml were like this:
After some invetigation, I have found that we should add a Log4jConfigListener in the first line (with the log4jConfigLocation) :
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
So the Web.xml become:
Wasn't easy to find but at least now it is done :)
hi,
ReplyDeleteYour before and after web.xml are same.
Thanks Sri for your remark, I didn;t notice that. It is fixed now.
DeleteHe added the listener-class which was not there in the first one.
ReplyDeleteThanks, it helped me. Now the log4j launch successfully.
ReplyDelete