public class StartupTriggeringPolicy<E> extends ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy<E>
Credit for the initial implementation belongs to this StackOverflow post.
| Constructor and Description |
|---|
StartupTriggeringPolicy() |
| Modifier and Type | Method and Description |
|---|---|
private Runnable |
asyncCleanFiles(int keep,
File[] files)
Creates a thread that attempts to remove all but the
keep oldest
files in files (by using the last modified times). |
private Runnable |
asyncCleanReallyOldFiles()
Removes log files archived by a very preliminary version of our Logback
configuration.
|
private Runnable |
asyncClearFiles(File oldDirectory,
File newDirectory,
File[] files)
Moves all files within
oldDirectory into newDirectory,
and then removes oldDirectory. |
private void |
cleanupArchivedLogs(int keepFiles)
Finds the archived log files and determines whether or not
asyncCleanFiles(int, java.io.File[])
should be called (and if it should, this method calls it). |
private void |
removeOldLogDirectory(File oldDirectory,
File newDirectory)
Fires off a thread that moves all files within
oldDirectory
into newDirectory, and then attempts to remove
oldDirectory. |
private void |
removePath(Path pathToRemove)
Convenience method that attempts to delete
pathToRemove. |
private void |
renameOldLogDirectory()
Responsible for determining what to do about the "logs" and
"archived_logs" subdirectory situation.
|
void |
start()
Triggers a "logback rollover" and calls
cleanupArchivedLogs(int). |
isTriggeringEvent, toStringcomputeNextCheck, getArchiveRemover, getCurrentPeriodsFileNameWithoutCompressionSuffix, getCurrentTime, getElapsedPeriodsFileName, isStarted, setCurrentTime, setDateInCurrentPeriod, setDateInCurrentPeriod, setTimeBasedRollingPolicy, stopaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextpublic StartupTriggeringPolicy()
private void renameOldLogDirectory()
private void removeOldLogDirectory(File oldDirectory, File newDirectory)
oldDirectory
into newDirectory, and then attempts to remove
oldDirectory.oldDirectory - "Old" log file directory. Be aware that
any files within this directory will be relocated to
newDirectory and this directory will then be removed. Cannot be
null.newDirectory - Destination for any files within
oldDirectory. Cannot be null.private Runnable asyncClearFiles(File oldDirectory, File newDirectory, File[] files)
oldDirectory into newDirectory,
and then removes oldDirectory.oldDirectory - "Old" log file directory. Cannot be
null.newDirectory - "New" log file directory. Cannot be
null.files - {link File Files} within oldDirectory that should
be moved to newDirectory. Cannot be null.oldDirectory to newDirectory and then attempt removal
of oldDirectory. Be aware that this thread has not yet had
"start" called.private void cleanupArchivedLogs(int keepFiles)
asyncCleanFiles(int, java.io.File[])
should be called (and if it should, this method calls it).keepFiles - Number of archived log files to keep around.private Runnable asyncCleanReallyOldFiles()
private void removePath(Path pathToRemove)
pathToRemove.pathToRemove - Path to the file to delete.
Cannot be null.private Runnable asyncCleanFiles(int keep, File[] files)
keep oldest
files in files (by using the last modified times).keep - Number of archived log files to keep around.files - Archived log files. Cannot be null.public void start()
cleanupArchivedLogs(int).start in interface ch.qos.logback.core.spi.LifeCyclestart in class ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy<E>