Writer
public final class RollingFileWriter extends Object implements Writer
FileWriter
but keeps backups of old
logging files.Constructor | Description |
---|---|
RollingFileWriter(String filename,
int backups) |
Rolling log files once at startup.
|
RollingFileWriter(String filename,
int backups,
boolean buffered) |
Rolling log files once at startup.
|
RollingFileWriter(String filename,
int backups,
boolean buffered,
Labeler labeler) |
Rolling log files once at startup.
|
RollingFileWriter(String filename,
int backups,
boolean buffered,
Labeler labeler,
Policy... policies) |
|
RollingFileWriter(String filename,
int backups,
boolean buffered,
Policy... policies) |
|
RollingFileWriter(String filename,
int backups,
Labeler labeler) |
Rolling log files once at startup.
|
RollingFileWriter(String filename,
int backups,
Labeler labeler,
Policy... policies) |
|
RollingFileWriter(String filename,
int backups,
Policy... policies) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close the log file.
|
void |
flush() |
Flush this writer and force any buffered data to output.
|
String |
getFilename() |
Get the filename of the current log file.
|
Labeler |
getLabeler() |
Get the labeler for naming backups.
|
int |
getNumberOfBackups() |
Get the maximum number of backups.
|
List<? extends Policy> |
getPolicies() |
Get the rollover strategies.
|
Set<LogEntryValue> |
getRequiredLogEntryValues() |
Get all log entry values that are required by this writer.
|
void |
init(Configuration configuration) |
Initialize the writer (open a file for example).
|
boolean |
isBuffered() |
Determine whether buffered writing is enabled.
|
void |
write(LogEntry logEntry) |
Write a log entry.
|
public RollingFileWriter(String filename, int backups)
filename
- Filename of the log filebackups
- Number of backupsStartupPolicy
public RollingFileWriter(String filename, int backups, boolean buffered)
filename
- Filename of the log filebackups
- Number of backupsbuffered
- Buffered writingStartupPolicy
public RollingFileWriter(String filename, int backups, Labeler labeler)
filename
- Filename of the log filebackups
- Number of backupslabeler
- Labeler for naming backupsStartupPolicy
public RollingFileWriter(String filename, int backups, boolean buffered, Labeler labeler)
filename
- Filename of the log filebackups
- Number of backupsbuffered
- Buffered writinglabeler
- Labeler for naming backupsStartupPolicy
public RollingFileWriter(String filename, int backups, Policy... policies)
filename
- Filename of the log filebackups
- Number of backupspolicies
- Rollover strategiespublic RollingFileWriter(String filename, int backups, boolean buffered, Policy... policies)
filename
- Filename of the log filebackups
- Number of backupsbuffered
- Buffered writingpolicies
- Rollover strategiespublic RollingFileWriter(String filename, int backups, Labeler labeler, Policy... policies)
filename
- Filename of the log filebackups
- Number of backupslabeler
- Labeler for naming backupspolicies
- Rollover strategiespublic RollingFileWriter(String filename, int backups, boolean buffered, Labeler labeler, Policy... policies)
filename
- Filename of the log filebackups
- Number of backupsbuffered
- Buffered writinglabeler
- Labeler for naming backupspolicies
- Rollover strategiespublic Set<LogEntryValue> getRequiredLogEntryValues()
Writer
getRequiredLogEntryValues
in interface Writer
public String getFilename()
public boolean isBuffered()
true
if buffered writing is enabled, otherwise false
public int getNumberOfBackups()
public Labeler getLabeler()
public List<? extends Policy> getPolicies()
public void init(Configuration configuration) throws IOException
Writer
init
in interface Writer
configuration
- Configuration of loggerIOException
public void write(LogEntry logEntry) throws IOException
Writer
write
in interface Writer
logEntry
- Log entry to outputIOException
public void flush() throws IOException
Writer
flush
in interface Writer
IOException
public void close() throws IOException
close
in interface Writer
IOException
- Failed to close the log fileCopyright © 2019. All rights reserved.