public class SizeRotatingFileHandler extends FileHandler
| Modifier and Type | Field and Description |
|---|---|
private int |
maxBackupIndex |
private CountingOutputStream |
outputStream |
private boolean |
rotateOnBoot |
private long |
rotateSize |
private java.lang.String |
suffix |
outputLockhandlers, handlersUpdater| Constructor and Description |
|---|
SizeRotatingFileHandler()
Construct a new instance with no formatter and no output file.
|
SizeRotatingFileHandler(java.io.File file)
Construct a new instance with the given output file.
|
SizeRotatingFileHandler(java.io.File file,
boolean append)
Construct a new instance with the given output file and append setting.
|
SizeRotatingFileHandler(java.io.File file,
boolean append,
long rotateSize,
int maxBackupIndex)
Construct a new instance with the given output file and append setting.
|
SizeRotatingFileHandler(java.io.File file,
long rotateSize,
int maxBackupIndex)
Construct a new instance with the given output file.
|
SizeRotatingFileHandler(long rotateSize,
int maxBackupIndex)
Construct a new instance with no formatter and no output file.
|
SizeRotatingFileHandler(java.lang.String fileName)
Construct a new instance with the given output file.
|
SizeRotatingFileHandler(java.lang.String fileName,
boolean append)
Construct a new instance with the given output file and append setting.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getSuffix()
Returns the suffix set to be appended to files during rotation.
|
boolean |
isRotateOnBoot()
Indicates whether or a not the handler should rotate the file before the first log record is written.
|
protected void |
preWrite(ExtLogRecord record)
Execute any pre-write policy, such as file rotation.
|
private void |
rotate(java.io.File file) |
void |
setFile(java.io.File file)
Set the output file.
|
void |
setMaxBackupIndex(int maxBackupIndex)
Set the maximum backup index (the number of log files to keep around).
|
void |
setOutputStream(java.io.OutputStream outputStream)
Set the output stream to write to.
|
void |
setRotateOnBoot(boolean rotateOnBoot)
Set to a value of
true if the file should be rotated before the a new file is set. |
void |
setRotateSize(long rotateSize)
Set the rotation size, in bytes.
|
void |
setSuffix(java.lang.String suffix)
Sets the suffix to be appended to the file name during the file rotation.
|
getFile, setAppend, setFileNamegetEncoding, setEncoding, setWriterclose, doPublish, flush, safeCloseaddHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotectprivate long rotateSize
private int maxBackupIndex
private CountingOutputStream outputStream
private boolean rotateOnBoot
private java.lang.String suffix
public SizeRotatingFileHandler()
public SizeRotatingFileHandler(java.io.File file)
throws java.io.FileNotFoundException
file - the filejava.io.FileNotFoundException - if the file could not be found on openpublic SizeRotatingFileHandler(java.io.File file,
boolean append)
throws java.io.FileNotFoundException
file - the fileappend - true to append, false to overwritejava.io.FileNotFoundException - if the file could not be found on openpublic SizeRotatingFileHandler(java.lang.String fileName)
throws java.io.FileNotFoundException
fileName - the file namejava.io.FileNotFoundException - if the file could not be found on openpublic SizeRotatingFileHandler(java.lang.String fileName,
boolean append)
throws java.io.FileNotFoundException
fileName - the file nameappend - true to append, false to overwritejava.io.FileNotFoundException - if the file could not be found on openpublic SizeRotatingFileHandler(long rotateSize,
int maxBackupIndex)
public SizeRotatingFileHandler(java.io.File file,
long rotateSize,
int maxBackupIndex)
throws java.io.FileNotFoundException
file - the filejava.io.FileNotFoundException - if the file could not be found on openpublic SizeRotatingFileHandler(java.io.File file,
boolean append,
long rotateSize,
int maxBackupIndex)
throws java.io.FileNotFoundException
file - the fileappend - true to append, false to overwritejava.io.FileNotFoundException - if the file could not be found on openpublic void setOutputStream(java.io.OutputStream outputStream)
setOutputStream in class OutputStreamHandleroutputStream - the new output stream or null for nonepublic void setFile(java.io.File file)
throws java.io.FileNotFoundException
setFile in class FileHandlerfile - the filejava.lang.RuntimeException - if there is an attempt to rotate file and the rotation failsjava.io.FileNotFoundException - if an error occurs opening the filepublic boolean isRotateOnBoot()
true if file should rotate on boot, otherwise false/public void setRotateOnBoot(boolean rotateOnBoot)
true if the file should be rotated before the a new file is set. The rotation only
happens if the file names are the same and the file has a length greater than 0.rotateOnBoot - true to rotate on boot, otherwise falsepublic void setRotateSize(long rotateSize)
rotateSize - the number of bytes before the log is rotatedpublic void setMaxBackupIndex(int maxBackupIndex)
maxBackupIndex - the maximum backup indexpublic java.lang.String getSuffix()
null if no suffix should be usedpublic void setSuffix(java.lang.String suffix)
SimpleDateFormat.
Note: Any files rotated with the suffix appended will not be deleted. The maxBackupIndex is not used for files with a suffix.suffix - the suffix to place after the filename when the file is rotatedprotected void preWrite(ExtLogRecord record)
preWrite in class WriterHandlerrecord - the record about to be loggedprivate void rotate(java.io.File file)
throws java.io.IOException
java.io.IOException