Package org.logevents.observers.file
Class FileRotationWorker
- java.lang.Object
-
- org.logevents.observers.file.FileRotationWorker
-
public class FileRotationWorker extends Object
Archives and expires old files based on file name patterns. ContainsactiveLogFilenameFormatter
andarchiveFilenameFormatter
with describes the format for the filenames for the current active logfile and archived logfiles respectively.Assumes that each day of logging for the active logfile will yield a unique archived logfile. If either FilenameFormatter contains variables from MDC or Marker, both should contain the same parameter set, or unique archived files cannot be created.
Assumes that
nextExecution()
should happen each at midnight according toConfiguration.getLocale()
-
-
Constructor Summary
Constructors Constructor Description FileRotationWorker(String filenamePattern, String archiveFilenamePattern, Configuration configuration)
FileRotationWorker(FilenameFormatter activeLogFilenameFormatter, FilenameFormatter archiveFilenameFormatter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FilenameFormatter
getActiveLogFilenameFormatter()
String
getArchiveName(String filename, ZonedDateTime fileCreationTime)
String
getArchiveName(ZonedDateTime fileTime)
ZonedDateTime
nextExecution()
void
rollover()
void
setCompressAfter(Period compressAfter)
void
setRetention(Period retention)
String
toString()
static void
transfer(InputStream in, OutputStream out)
-
-
-
Constructor Detail
-
FileRotationWorker
public FileRotationWorker(FilenameFormatter activeLogFilenameFormatter, FilenameFormatter archiveFilenameFormatter)
-
FileRotationWorker
public FileRotationWorker(String filenamePattern, String archiveFilenamePattern, Configuration configuration)
-
-
Method Detail
-
getActiveLogFilenameFormatter
public FilenameFormatter getActiveLogFilenameFormatter()
-
setRetention
public void setRetention(Period retention)
-
setCompressAfter
public void setCompressAfter(Period compressAfter)
-
rollover
public void rollover()
-
getArchiveName
public String getArchiveName(String filename, ZonedDateTime fileCreationTime)
-
transfer
public static void transfer(InputStream in, OutputStream out) throws IOException
- Throws:
IOException
-
getArchiveName
public String getArchiveName(ZonedDateTime fileTime)
-
nextExecution
public ZonedDateTime nextExecution()
-
-