Announcement Announcement Module
Collapse
No announcement yet.
Log4j Configuration suppress warning message on context startup Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Log4j Configuration suppress warning message on context startup

    I have configured log4j to utilize a environment property to read in log4j and other startup properties based on the server being deployed on.

    Code:
      <bean id="log4jInitializer"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="staticMethod">
          <value>org.springframework.util.Log4jConfigurer.initLogging</value>
        </property>
        <property name="arguments">
          <list>
            <value>${config}/log4j.properties</value>
          </list>
        </property>
      </bean>
    The logger is initialized correctly based on location without problems. However, a logger warning message is output to the console since Spring wants to log before the Log4jConfigurer is initialized. This outputs the following message.

    Code:
    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
    log4j:WARN Please initialize the log4j system properly.
    I can suppress the warning message by putting a default log4j.properties in the class path that turns off all org.springframework logging but it there a better way without including this file in every webapp? I have read the thread (/showthread.php?t=15909) about the same issue but didn't see a solution to this without using a class to configure log4j.



    Thanks,
    Brian
Working...
X