log4j:WARN No appenders could be found for logger in web.xml

cometta picture cometta · Aug 12, 2009 · Viewed 299k times · Source

I already put the log4jConfigLocation in web.xml, but I still get the following warning:

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

What did I miss?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
    </listener>
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>suara2</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>suara2</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

Answer

CodeGoat picture CodeGoat · Aug 12, 2009

If that's the entire log4j.properties file it looks like you're never actually creating a logger. You need a line like:

log4j.rootLogger=debug,A1