public class PeriodicSizeRotatingFileHandler extends PeriodicRotatingFileHandler
PeriodicRotatingFileHandler.setSuffix(String)
.
The size interval is determined by the value passed in the setRotateSize(long)
.PeriodicRotatingFileHandler.Period
Modifier and Type | Field and Description |
---|---|
private int |
maxBackupIndex |
private CountingOutputStream |
outputStream |
private boolean |
rotateOnBoot |
private long |
rotateSize |
outputLock
handlers, handlersUpdater
Constructor and Description |
---|
PeriodicSizeRotatingFileHandler()
Default constructor.
|
PeriodicSizeRotatingFileHandler(java.io.File file,
java.lang.String suffix)
Construct a new instance with the given output file.
|
PeriodicSizeRotatingFileHandler(java.io.File file,
java.lang.String suffix,
boolean append)
Construct a new instance with the given output file and append setting.
|
PeriodicSizeRotatingFileHandler(java.io.File file,
java.lang.String suffix,
long rotateSize,
int maxBackupIndex)
Construct a new instance with the given output file.
|
PeriodicSizeRotatingFileHandler(java.io.File file,
java.lang.String suffix,
long rotateSize,
int maxBackupIndex,
boolean append)
Construct a new instance with the given output file.
|
PeriodicSizeRotatingFileHandler(java.lang.String fileName)
Construct a new instance with the given output file.
|
PeriodicSizeRotatingFileHandler(java.lang.String fileName,
boolean append)
Construct a new instance with the given output file and append setting.
|
Modifier and Type | Method and Description |
---|---|
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.
|
getNextSuffix, getTimeZone, setSuffix, setTimeZone
getFile, setAppend, setFileName
getEncoding, setEncoding, setWriter
close, doPublish, flush, safeClose
addHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotect
private long rotateSize
private int maxBackupIndex
private CountingOutputStream outputStream
private boolean rotateOnBoot
public PeriodicSizeRotatingFileHandler()
public PeriodicSizeRotatingFileHandler(java.lang.String fileName) throws java.io.FileNotFoundException
fileName
- the file namejava.io.FileNotFoundException
- if the file could not be found on openpublic PeriodicSizeRotatingFileHandler(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 PeriodicSizeRotatingFileHandler(java.io.File file, java.lang.String suffix) throws java.io.FileNotFoundException
file
- the filesuffix
- the format suffix to usejava.io.FileNotFoundException
- if the file could not be found on openpublic PeriodicSizeRotatingFileHandler(java.io.File file, java.lang.String suffix, boolean append) throws java.io.FileNotFoundException
file
- the filesuffix
- the format suffix to useappend
- true
to append, false
to overwritejava.io.FileNotFoundException
- if the file could not be found on openpublic PeriodicSizeRotatingFileHandler(java.io.File file, java.lang.String suffix, long rotateSize, int maxBackupIndex) throws java.io.FileNotFoundException
file
- the filesuffix
- the format suffix to userotateSize
- the size the file should rotate atmaxBackupIndex
- the maximum number of files to backupjava.io.FileNotFoundException
- if the file could not be found on openpublic PeriodicSizeRotatingFileHandler(java.io.File file, java.lang.String suffix, long rotateSize, int maxBackupIndex, boolean append) throws java.io.FileNotFoundException
file
- the filesuffix
- the format suffix to userotateSize
- the size the file should rotate atmaxBackupIndex
- the maximum number of files to backupappend
- true
to append, false
to overwritejava.io.FileNotFoundException
- if the file could not be found on openpublic void setOutputStream(java.io.OutputStream outputStream)
OutputStreamHandler
setOutputStream
in class OutputStreamHandler
outputStream
- the new output stream or null
for nonepublic void setFile(java.io.File file) throws java.io.FileNotFoundException
setFile
in class PeriodicRotatingFileHandler
file
- 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 false
public void setRotateSize(long rotateSize)
rotateSize
- the number of bytes before the log is rotatedpublic void setMaxBackupIndex(int maxBackupIndex)
maxBackupIndex
- the maximum backup indexprotected void preWrite(ExtLogRecord record)
PeriodicRotatingFileHandler
preWrite
in class PeriodicRotatingFileHandler
record
- the record about to be loggedprivate void rotate(java.io.File file) throws java.io.IOException
java.io.IOException