| Method from org.apache.log4j.DailyFileAppender Detail: |
public void activateOptions() {
try {
setFile(null, super.fileAppend);
}
catch(java.io.IOException e) {
errorHandler.error("setFile(null,"+fileAppend+") call failed.",
e, ErrorCode.FILE_OPEN_FAILURE);
}
}
|
public String[] getOptionStrings() {
return OptionConverter.concatanateArrays(super.getOptionStrings(),
new String[] {FILE_NAME_PATTERN_OPTION});
}
|
public synchronized void setFile(String fileName,
boolean append) throws IOException {
/* Compute filename, but only if fileNamePattern is specified */
if (fileNamePattern == null) {
errorHandler.error("Missing file pattern (" + FILE_NAME_PATTERN_OPTION + ") in setFile().");
return;
}
Date now = new Date();
fileName = new SimpleDateFormat(fileNamePattern).format (now);
if (fileName.equals(currentFileName))
return;
/* Set up next filename checkpoint */
DailyFileAppenderCalendar c = new DailyFileAppenderCalendar();
c.rollToNextDay ();
nextFilenameComputingMillis = c.getTimeInMillis ();
currentFileName = fileName;
super.setFile(fileName, append);
}
Set the current output file.
The function will compute a new filename, and open a new file only
when the name has changed.
The function is automatically called once a day, to allow for
daily files -- the purpose of this class. |
public void setOption(String key,
String value) {
super.setOption(key, value);
if(key.equalsIgnoreCase(FILE_NAME_PATTERN_OPTION)) {
fileNamePattern = value;
}
}
Set the options for the appender |
protected void subAppend(LoggingEvent event) {
if (System.currentTimeMillis () >= nextFilenameComputingMillis) {
try {
setFile (super.fileName, super.fileAppend);
}
catch(IOException e) {
System.err.println("setFile(null, false) call failed.");
e.printStackTrace();
}
}
super.subAppend(event);
}
This method differentiates RollingFileAppender from its super
class. |