title: grails configure log4j without rebuilding war?
body: <p>This seems pretty strange, but when grails builds a war file it doesn't generate a log4j.properties or log4j.xml file. </p>
  
  <p>Instead it has the following in WEB-INF/web.xml</p>
  
  <p>web.xml:
  <code><pre>
   &lt;listener&gt;
      &lt;listener-class&gt;org.codehaus.groovy.grails.web.util.Log4jConfigListener&lt;/listener-class&gt;
   &lt;/listener&gt;
  </pre></code></p>
  
  <p>and apparently "grails Log4j DSL configures logging in-memory". The problem here is - log4j isn't automatically exposed to JMX for us to dynamically change and there's no log4j file generated by grails. But Config.groovy is a compiled file. </p>
  
  <p>There's got to be an easy way to manage this without rebuilding the war? </p>
  
  <p>One option suggested is go through to spring and configure logging there:</p>
  
  <p>resources.groovy:
  <code><pre>
  beans = {<br>
   log4jConfigurer(org.springframework.beans.factory.config.MethodInvokingFactoryBean) 
   {
      targetClass = "org.springframework.util.Log4jConfigurer"
      targetMethod = "initLogging"
      arguments = ["classpath:myapp/log4j.properties"]
   }
  }
  </pre></code></p>
  
  <p>then shift the configuration in the DSL to the configured file.</p>
  
  <p>Can anyone advise the 'groovy' way to dynamically change logging configuration without rebuilding the WAR file each time. Using grails-1.3.7. Cutting the DSL out doesn't seem the right way.</p>
  
  <p>Thanks</p>