You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Dan <da...@mcenter.com> on 2002/11/12 18:53:17 UTC
re: DailyRollingFileAppender does not create backup file
I'm using the DailyRollingFileAppender (DRFA) from the most recent stable
log4j release. The application runs under Win2K in TomCat.
When I run the class in my IDE (netbeans), the DRFA works fine (except when
noted below). When the class is run in Tomcat (being called via a JSP
page) it usually "fails" (the old access.log file is overwritten with a new
access.log and no backup was created).
I've found that if I run the class under Forte and keep it running (the
process doesn't end) and then run a second instance (separate process) of
the class, the DRFA will not rename the file (giving a can't rename
message).
log4j:ERROR Failed to rename [E:\vns\access.log] to
[E:\vns\access.log.2002-11-12-11-53].
It appears that there's an issue here between "who" has the rights to the
file under Win2K. As long as process A is still running, when process B
sends a log event (log.info()) which would require the DRFA to rollover, it
cannot rename the file under Win2K because it is "open" by process A, even
though process B uses the same DRFA as process B does. Does this make any
sense or is there something else going on here?
VNSAccess' log4j fields:
static org.apache.log4j.Logger log =
org.apache.log4j.Logger.getLogger(VNSAccess.class.getName());
protected static java.io.File logFile = new
java.io.File(VNSUtils.UPDATE_PROCESS_DIR, "access.log");
protected static org.apache.log4j.Layout logLayout = new
org.apache.log4j.TTCCLayout("ISO8601");
protected static org.apache.log4j.DailyRollingFileAppender
logFileAppender = null;
private org.apache.log4j.MDC logMDC;
VNSAccess' constructor:
public VNSAccess() {
try {
if (logFileAppender == null) {
org.apache.log4j.BasicConfigurator.configure();
logFileAppender = new
org.apache.log4j.DailyRollingFileAppender(
logLayout, logFile.toString(),
"'.'yyyy-MM-dd-HH-mm"); //'.'yyyy-MM-dd" );
logFileAppender.activateOptions();
log.addAppender(logFileAppender);
}
} catch (Exception e) {
e.printStackTrace();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>