logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xi Yuxiang" <x...@hotmail.com>
Subject log4j:ERROR Failed to rename issue
Date Thu, 26 Feb 2004 09:10:31 GMT
Hi, I met a strange multi-thread problem on log4j-DailyRollingFileAppender

If there's two separate class, ClassA.java and ClassB.java

Each class has its main method. and they will invoke logger.info("message 
from class a/b"); for every 3 seconds. as attached below. when day rolls, 
the screen will echo log4j:ERROR Failed to rename [e:/sms] to 

This issue happens when two threads are running and using log4j.

I checked the code in DailyRollingFileAppender 

    boolean result = file.renameTo(target);
    if(result) {
      LogLog.debug(fileName +" -> "+ scheduledFilename);
    } else {
      LogLog.error("Failed to rename ["+fileName+"] to 

as list above, i don't think it's security issue. if so, the 
File.renameTo() will throw a SecurityException, and the code cannot run to 
'Failed to rename...'

Anybody has idea on this issue?

I'm using log4j-1.2.8, JDK1.4.2_03-b02, Windows 2000 Professional

import org.apache.log4j.Logger;
 * @author Xi Yuxiang
 * @version 1.0
public class ClassA {
  public ClassA() {
  private static Logger logger = Logger.getLogger(ClassA.class);
  public static void main(String[] args) {
      logger.info("message from class a");
      try {
      catch (Exception ex) {        

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited  by Xi Yuxiang -->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
 <appender name="fileAppender" 
  <param name="File" value="e:/sms"/>
  <param name="ImmediateFlush" value="true"/>
  <param name="DatePattern" value="'.'yyyy-MM-dd"/>
  <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern" value="%m [%d]%n"/>
  <priority value="DEBUG"/>
  <appender-ref ref="fileAppender"/>

免费下载 MSN Explorer:   http://explorer.msn.com/lccn/  

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message