title: Why is RollingFileAppender for log4j not logging in Spring MVC?
body: <p>I'm trying to set up log4j for use in a Spring MVC webapp. stdout logging is working perfectly, but neither RollingFileAdapter nor FileAdapter have been able to print my log to a file. 
  Here's my log4j.properties file:</p>
  
  <pre><code># Root logger option  
  log4j.rootLogger=INFO, file, stdout
  # Direct log messages to a log file  
  log4j.appender.file=org.apache.log4j.RollingFileAppender  
  log4j.appender.file.File=~/logger.log 
  log4j.appender.file.MaxFileSize=100MB  
  log4j.appender.file.MaxBackupIndex=1  
  log4j.appender.file.layout=org.apache.log4j.PatternLayout  
  log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L -     %m%n
  
  # Direct log messages to stdout  
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender  
  log4j.appender.stdout.Target=System.out  
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout  
  log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L -     %m%n
  </code></pre>
  
  <p>In web.xml I've defined the listener:</p>
  
  <pre><code>&lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  
  <p>and the context parameter:</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/classes/log4j.properties&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>I'm using Maven and define the dependency using:</p>
  
  <pre><code>&lt;dependency&gt;  
      &lt;groupId&gt;log4j&lt;/groupId&gt;  
      &lt;artifactId&gt;log4j&lt;/artifactId&gt;  
      &lt;version&gt;1.2.12&lt;/version&gt;
  &lt;/dependency&gt; 
  </code></pre>
  
  <p>In my controller I instantiate the logger using</p>
  
  <pre><code>private static final Logger logger = Logger.getLogger(DeviceController.class); 
  </code></pre>
  
  <p>and test it in a method using</p>
  
  <pre><code>//Implement required logging method
  logger.debug("Debug.."); 
  logger.info("Info..");
  logger.error("Error..");
  logger.fatal("Fatal");
  logger.trace("trace");
  </code></pre>
  
  <p>I'm using Ubuntu 12.04 and Spring MVC3. I've tried several directories for the logging file and have pre-created the paths each time. </p>
  
  <p>I should add I'm also getting the following unexplained error:</p>
  
  <pre><code>An error occurred while filtering resources PolicyManager line 1 Maven Configuration Problem
  </code></pre>
  
  <p>but it still compiles and stdout logging works.</p>
  
  <p>Does anyone have any suggestions as to why the log file is not being created and/or appended?</p>