Top Fields Constructors Methods
org.jboss.logmanager.handlers

public Class SizeRotatingFileHandler

extends FileHandler
Class Inheritance
Imports
java.io.File, .FileNotFoundException, .IOException, .OutputStream, .UncheckedIOException, java.security.AccessControlContext, .AccessController, .PrivilegedAction, java.util.logging.ErrorManager, org.jboss.logmanager.ExtLogRecord

Field Summary

Modifier and TypeField and Description
private final AccessControlContext
acc

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
private int
private CountingOutputStream
private boolean
private long
private SuffixRotator

Constructor Summary

AccessConstructor and Description
public
SizeRotatingFileHandler()

Construct a new instance with no formatter and no output file.

public
SizeRotatingFileHandler(final File
the file
file
)

Construct a new instance with the given output file.

public
SizeRotatingFileHandler(final File
the file
file
,
final boolean
true to append, false to overwrite
append
)

Construct a new instance with the given output file and append setting.

public
SizeRotatingFileHandler(final String
the file name
fileName
)

Construct a new instance with the given output file.

public
SizeRotatingFileHandler(final String
the file name
fileName
,
final boolean
true to append, false to overwrite
append
)

Construct a new instance with the given output file and append setting.

public
SizeRotatingFileHandler(final long rotateSize, final int maxBackupIndex)

Construct a new instance with no formatter and no output file.

public
SizeRotatingFileHandler(final File
the file
file
,
final long rotateSize, final int maxBackupIndex)

Construct a new instance with the given output file.

public
SizeRotatingFileHandler(final File
the file
file
,
final boolean
true to append, false to overwrite
append
,
final long rotateSize, final int maxBackupIndex)

Construct a new instance with the given output file and append setting.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the suffix or null if no suffix should be used
getSuffix
()

Returns the suffix set to be appended to files during rotation.

public boolean

Returns:

true if file should rotate on boot, otherwise false/
isRotateOnBoot
()

Indicates whether or a not the handler should rotate the file before the first log record is written.

protected void
preWrite(final ExtLogRecord
the record about to be logged
record
)

Overrides org.jboss.logmanager.handlers.WriterHandler.preWrite.

Execute any pre-write policy, such as file rotation.

public void
setFile(final File
the file
file
)

Overrides org.jboss.logmanager.handlers.FileHandler.setFile.

Set the output file.

private void
setFileInternal(final File file, final boolean doPrivileged)

public void
setMaxBackupIndex(final int
the maximum backup index
maxBackupIndex
)

Set the maximum backup index (the number of log files to keep around).

public void
setOutputStream(final OutputStream
the new output stream or null for none
outputStream
)

Overrides org.jboss.logmanager.handlers.OutputStreamHandler.setOutputStream.

Set the output stream to write to.

public void
setRotateOnBoot(final boolean
true to rotate on boot, otherwise false
rotateOnBoot
)

Set to a value of true if the file should be rotated before the a new file is set.

public void
setRotateSize(final long
the number of bytes before the log is rotated
rotateSize
)

Set the rotation size, in bytes.

public void
setSuffix(final String
the suffix to place after the filename when the file is rotated
suffix
)

Sets the suffix to be appended to the file name during the file rotation.

Inherited from org.jboss.logmanager.handlers.FileHandler:
getFilesetAppendsetFileName

Field Detail

accback to summary
private final AccessControlContext acc

References Deprecated

AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

maxBackupIndexback to summary
private int maxBackupIndex
outputStreamback to summary
private CountingOutputStream outputStream

Hides org.jboss.logmanager.handlers.OutputStreamHandler.outputStream.

rotateOnBootback to summary
private boolean rotateOnBoot
rotateSizeback to summary
private long rotateSize
suffixRotatorback to summary
private SuffixRotator suffixRotator

Constructor Detail

SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler()

Construct a new instance with no formatter and no output file.

SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final File file) throws FileNotFoundException

Construct a new instance with the given output file.

Parameters
file:File

the file

Exceptions
FileNotFoundException:
if the file could not be found on open
SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final File file, final boolean append) throws FileNotFoundException

Construct a new instance with the given output file and append setting.

Parameters
file:File

the file

append:boolean

true to append, false to overwrite

Exceptions
FileNotFoundException:
if the file could not be found on open
SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final String fileName) throws FileNotFoundException

Construct a new instance with the given output file.

Parameters
fileName:String

the file name

Exceptions
FileNotFoundException:
if the file could not be found on open
SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final String fileName, final boolean append) throws FileNotFoundException

Construct a new instance with the given output file and append setting.

Parameters
fileName:String

the file name

append:boolean

true to append, false to overwrite

Exceptions
FileNotFoundException:
if the file could not be found on open
SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final long rotateSize, final int maxBackupIndex)

Construct a new instance with no formatter and no output file.

SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final File file, final long rotateSize, final int maxBackupIndex) throws FileNotFoundException

Construct a new instance with the given output file.

Parameters
file:File

the file

Exceptions
FileNotFoundException:
if the file could not be found on open
SizeRotatingFileHandlerback to summary
public SizeRotatingFileHandler(final File file, final boolean append, final long rotateSize, final int maxBackupIndex) throws FileNotFoundException

Construct a new instance with the given output file and append setting.

Parameters
file:File

the file

append:boolean

true to append, false to overwrite

Exceptions
FileNotFoundException:
if the file could not be found on open

Method Detail

getSuffixback to summary
public String getSuffix()

Returns the suffix set to be appended to files during rotation.

Returns:String

the suffix or null if no suffix should be used

isRotateOnBootback to summary
public boolean isRotateOnBoot()

Indicates whether or a not the handler should rotate the file before the first log record is written.

Returns:boolean

true if file should rotate on boot, otherwise false/

preWriteback to summary
protected void preWrite(final ExtLogRecord record)

Overrides org.jboss.logmanager.handlers.WriterHandler.preWrite.

Doc from org.jboss.logmanager.handlers.WriterHandler.preWrite.

Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing.

Parameters
record:ExtLogRecord

the record about to be logged

setFileback to summary
public void setFile(final File file) throws FileNotFoundException

Overrides org.jboss.logmanager.handlers.FileHandler.setFile.

Doc from org.jboss.logmanager.handlers.FileHandler.setFile.

Set the output file.

Parameters
file:File

the file

Exceptions
FileNotFoundException:
if an error occurs opening the file
RuntimeException:
if there is an attempt to rotate file and the rotation fails
setFileInternalback to summary
private void setFileInternal(final File file, final boolean doPrivileged) throws FileNotFoundException
setMaxBackupIndexback to summary
public void setMaxBackupIndex(final int maxBackupIndex)

Set the maximum backup index (the number of log files to keep around).

Parameters
maxBackupIndex:int

the maximum backup index

setOutputStreamback to summary
public void setOutputStream(final OutputStream outputStream)

Overrides org.jboss.logmanager.handlers.OutputStreamHandler.setOutputStream.

Doc from org.jboss.logmanager.handlers.OutputStreamHandler.setOutputStream.

Set the output stream to write to. The output stream will then belong to this handler; when the handler is closed or a new writer or output stream is set, this output stream will be closed.

Parameters
outputStream:OutputStream

the new output stream or null for none

setRotateOnBootback to summary
public void setRotateOnBoot(final boolean rotateOnBoot)

Set to a value of 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.

Parameters
rotateOnBoot:boolean

true to rotate on boot, otherwise false

setRotateSizeback to summary
public void setRotateSize(final long rotateSize)

Set the rotation size, in bytes.

Parameters
rotateSize:long

the number of bytes before the log is rotated

setSuffixback to summary
public void setSuffix(final String suffix)

Sets the suffix to be appended to the file name during the file rotation. The suffix does not play a role in determining when the file should be rotated.

The suffix must be a string understood by the java.text.SimpleDateFormat. Optionally the suffix can end with .gz or .zip which will compress the file on rotation.

If the suffix ends with .gz or .zip the file will be compressed on rotation.

Note

The maxBackupIndex only takes into account files rotated with same suffix. For example if the suffix pattern is .yyyy-MM-dd and the size rotation is reached only files with the same date suffix will be purged. A file the day before or after will not be purged.

Parameters
suffix:String

the suffix to place after the filename when the file is rotated