title: Initializing Log4J with Spring?
body: <p>I have a web app that uses Spring's <code>Log4jConfigurer</code> class to initialize my Log4J log factory.  Basically it initializes Log4J with a config file that is off the class path.</p>
  
  <p>Here is the config:</p>
  
  <pre><code>&lt;bean id="log4jInitializer" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="sbeHome"&gt;
      &lt;property name="targetClass" value="org.springframework.util.Log4jConfigurer" /&gt;
      &lt;property name="targetMethod" value="initLogging" /&gt;
      &lt;property name="arguments"&gt;
          &lt;list&gt;
              &lt;value&gt;#{ MyAppHome + '/conf/log4j.xml'}&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>However I get this error at application startup:</p>
  
  <p><code>log4j:WARN No appenders could be found for logger</code></p>
  
  <p>and tons of Spring application context initialization messages are printed to the console.  I think this is because Spring is doing work to initialize my application before it has a chance to initialize my logger.  In case it matters, I am using SLF4J on top of Log4J.   </p>
  
  <p>Is there some way I can get my Log4jConfigurer to be the first bean initialized?  or is there some other way to solve this?</p>