public class RotatingFileLogger extends FileLogger implements Schedulable
This subclass of FileLogger will "rotate" logs according to a schedule. When the logs are rotated, the current log is compressed, "zipped", and written to the logArchivePath, with the name "{logfile}.0.zip". If there is already a "{logfile}.0.zip" in existence, then it is renamed to "{logfile}.1.zip", and so on. A maximum archive count specifies the highest numbered log file to be stored, after which the oldest archive files are removed.
Log files are only "zipped" if the "archiveCompressed" flag is set to true. Otherwise, the log files are copied as-is, and do not have the ".zip" extension.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
mLogFileName, mLogFilePathSERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
RotatingFileLogger()
Constructs a new RotatingFileLogger
|
| Modifier and Type | Method and Description |
|---|---|
void |
doStartService()
Schedules the rotation
|
void |
doStopService()
Unschedules the rotation
|
java.io.File |
getLogArchivePath()
Returns the path used to store rotated log archives
|
int |
getMaximumArchiveCount()
Returns the maximum number of archived files that will be kept
for this file.
|
Schedule |
getSchedule()
Returns the Schedule that is used to schedule rotations
|
Scheduler |
getScheduler()
Returns the Scheduler that is used to schedule rotations
|
boolean |
isArchiveCompressed()
Returns the flag indicating if the archive files are compressed
when rotated.
|
void |
performScheduledTask(Scheduler pScheduler,
ScheduledJob pJob)
Performs the log rotation
|
void |
rotateCompressedLogs()
Rotates the compressed log files
|
void |
rotateLogs()
Rotates the log files
|
void |
rotateUncompressedLogs()
Rotates the uncompressed log files
|
void |
setArchiveCompressed(boolean pArchiveCompressed)
Sets the flag indicating if the archive files are compressed when
rotated.
|
void |
setLogArchivePath(java.io.File pLogArchivePath)
Sets the path used to store rotated log archives
|
void |
setMaximumArchiveCount(int pMaximumArchiveCount)
Sets the maximum number of archived files that will be kept for
this file.
|
void |
setSchedule(Schedule pSchedule)
Sets the Schedule that is used to schedule rotations
|
void |
setScheduler(Scheduler pScheduler)
Sets the Scheduler that is used to schedule rotations
|
close, flush, getLogFileName, getLogFilePath, open, setLogFileName, setLogFilePathgenerateCroppedStackTrace, getLoggingEnabled, getLogStream, getMaxLinesInStackTrace, getPrefixLogStream, getPrintStackTrace, getWrittenEventCount, isCropStackTrace, isPrefixEachLine, isPrefixEachMessage, isSuppressTimestamp, logEvent, setCropStackTrace, setLoggingEnabled, setLogStream, setMaxLinesInStackTrace, setPrefixEachLine, setPrefixEachMessage, setPrefixLogStream, setPrintStackTrace, setSuppressTimestamp, writeLogEventaddLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningpublic RotatingFileLogger()
public Scheduler getScheduler()
public void setScheduler(Scheduler pScheduler)
public Schedule getSchedule()
public void setSchedule(Schedule pSchedule)
public java.io.File getLogArchivePath()
public void setLogArchivePath(java.io.File pLogArchivePath)
public int getMaximumArchiveCount()
public void setMaximumArchiveCount(int pMaximumArchiveCount)
public boolean isArchiveCompressed()
public void setArchiveCompressed(boolean pArchiveCompressed)
public void doStartService()
throws ServiceException
doStartService in class FileLoggerServiceException - if an error occurred during the operationpublic void doStopService()
throws ServiceException
doStopService in class FileLoggerServiceException - if an error occurred during the operationpublic void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
performScheduledTask in interface SchedulablepScheduler - calling the jobpJob - the ScheduledJobpublic void rotateLogs()
public void rotateUncompressedLogs()
public void rotateCompressedLogs()