Sunday, April 20, 2014

Resolved : log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)

Removed
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 :)

4 comments :

  1. hi,
    Your before and after web.xml are same.

    ReplyDelete
    Replies
    1. Thanks Sri for your remark, I didn;t notice that. It is fixed now.

      Delete
  2. He added the listener-class which was not there in the first one.

    ReplyDelete
  3. Thanks, it helped me. Now the log4j launch successfully.

    ReplyDelete

Articles les plus consultés