title: log4j:ERROR Failed to rename
body: <p>I get this error "log4j:ERROR Failed to rename" in my tomcat server log.
  I have multiple DailyRollingFileAppender in my log4j XML. And each appender points to different file. Only once instance of the application is running.
  I used Handle utility and run the command (with log file name as parameter)</p>
  
  <p>handle -f ams-app.log
  and the result is 
  Tomcat7.exe        pid: 5032   type: File   54C: E:\apps\ams\logs\ams-app.log</p>
  
  <p>From this I assume there is  only one lock on the file.
  My environment Windows Server 2008, tomcat 7.0 and Java 6 and slf4j-log4j12(1.5.6)</p>
  
  <p>This problem was not happening when same application hosted on AIX server.
  I googled this problem and it seems to be windows specfic.
  Also I am not keen to use DatedFileAppenders or any forked log4j.
  Does logback solve such issues.
  Any suggestions on how to solve this problem is appreciated.
  Thanks</p>
  
  <p>here my log4j xml</p>
  
  <pre><code>&lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
  &lt;appender name="CONSOLE_APPENDER" class="org.apache.log4j.ConsoleAppender"&gt;
      &lt;errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/&gt;
      &lt;param name="Target" value="System.out"/&gt;
      &lt;param name="Threshold" value="DEBUG"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;     
          &lt;param name="ConversionPattern" value="%n %d{yyyy/MM/dd HH:mm:ss} %-5p %x %M(%F:%L) - %m  %n"/&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;appender name="APP_APPENDER" class="org.apache.log4j.DailyRollingFileAppender"&gt;
      &lt;errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/&gt;
      &lt;param name="datePattern" value="yyyy-MM-dd"/&gt;
      &lt;param name="file" value="E:/apps/ams/logs/ams-app.log"/&gt;
      &lt;param name="append" value="true"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%n %d{yyyy/MM/dd HH:mm:ss} %-5p %x %M(%F:%L) - %m  %n"/&gt;
      &lt;/layout&gt;        
  &lt;/appender&gt;
  
  &lt;appender name="SQL_APPENDER" class="org.apache.log4j.DailyRollingFileAppender"&gt;
      &lt;errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/&gt;
      &lt;param name="datePattern" value="yyyy-MM-dd"/&gt;
      &lt;param name="file" value="E:/apps/ams/logs/ams-sql.log"/&gt;
      &lt;param name="append" value="true"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%n %d{yyyy/MM/dd HH:mm:ss} %-5p %x %M(%F:%L) - %m  %n"/&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;appender name="Quartz_APPENDER" class="org.apache.log4j.DailyRollingFileAppender"&gt;
      &lt;errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/&gt;
      &lt;param name="datePattern" value="yyyy-MM-dd"/&gt;
      &lt;param name="file" value="E:/apps/ams/logs/ams-Quartz.log"/&gt;
      &lt;param name="append" value="true"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%n %d{yyyy/MM/dd HH:mm:ss} %-5p %x %M(%F:%L) - %m  %n"/&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  
  &lt;logger name="org.springframework"&gt;&lt;level value="WARN"/&gt;&lt;/logger&gt;
  &lt;logger name="flex.messaging.log.ServletLogTarget"&gt;&lt;level value="WARN" /&gt;&lt;/logger&gt;
  &lt;logger name="net.sf.jasperreports"&gt;&lt;level value="WARN" /&gt;&lt;/logger&gt;
  &lt;logger name="net.sf.jasperreports.engine.fill"&gt;&lt;level value="WARN" /&gt;&lt;/logger&gt; 
  &lt;logger name="org.apache.commons.beanutils"&gt;&lt;level value="WARN" /&gt;&lt;/logger&gt;
  &lt;logger name="jdbc.sqltiming" additivity="false"&gt;&lt;level value="DEBUG"/&gt;&lt;appender-ref ref="SQL_APPENDER"/&gt;&lt;/logger&gt;
  &lt;logger name="org.quartz" additivity="false"&gt;&lt;level value="WARN" /&gt;&lt;appender-ref ref="Quartz_APPENDER"/&gt;&lt;/logger&gt;
  &lt;logger name="org.quartz.SchedulerException"&gt;&lt;level value="ERROR" /&gt;&lt;appender-ref ref="MAIL_APPENDER"/&gt;&lt;/logger&gt;     
  &lt;logger name="org.hmil.ams.BatchDAO" additivity="false"&gt;&lt;level value="INFO"/&gt;&lt;appender-ref ref="Quartz_APPENDER"/&gt;&lt;/logger&gt;
  &lt;root&gt;      
      &lt;priority value="debug"&gt;&lt;/priority&gt; 
      &lt;appender-ref ref="APP_APPENDER" /&gt;      
      &lt;appender-ref ref="CONSOLE_APPENDER"/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p></p>