Top Description Fields Constructors Methods
org.jboss.logmanager.handlers

public Class PeriodicSizeRotatingFileHandler

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

A file handler which rotates the log at a preset time interval or the size of the log.

The time interval is determined by the content of the suffix string which is passed in to setSuffix(String).

The size interval is determined by the value passed in the setRotateSize(long).

Author
James R. Perkins

Field Summary

Modifier and TypeField and Description
private final AccessControlContext
acc

Hides org.jboss.logmanager.handlers.PeriodicRotatingFileHandler.acc.

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

Constructor Summary

AccessConstructor and Description
public
PeriodicSizeRotatingFileHandler()

Default constructor.

public
PeriodicSizeRotatingFileHandler(final String
the file name
fileName
)

Construct a new instance with the given output file.

public
PeriodicSizeRotatingFileHandler(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
PeriodicSizeRotatingFileHandler(final File
the file
file
,
final String
the format suffix to use
suffix
)

Construct a new instance with the given output file.

public
PeriodicSizeRotatingFileHandler(final File
the file
file
,
final String
the format suffix to use
suffix
,
final boolean
true to append, false to overwrite
append
)

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

public
PeriodicSizeRotatingFileHandler(final File
the file
file
,
final String
the format suffix to use
suffix
,
final long
the size the file should rotate at
rotateSize
,
final int
the maximum number of files to backup
maxBackupIndex
)

Construct a new instance with the given output file.

public
PeriodicSizeRotatingFileHandler(final File
the file
file
,
final String
the format suffix to use
suffix
,
final long
the size the file should rotate at
rotateSize
,
final int
the maximum number of files to backup
maxBackupIndex
,
final boolean
true to append, false to overwrite
append
)

Construct a new instance with the given output file.

Method Summary

Modifier and TypeMethod and Description
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.PeriodicRotatingFileHandler.preWrite.

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

public void
setFile(final File
the file
file
)

Overrides org.jboss.logmanager.handlers.PeriodicRotatingFileHandler.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.

Inherited from org.jboss.logmanager.handlers.PeriodicRotatingFileHandler:
getNextSuffixgetSuffixRotatorgetTimeZonesetSuffixsetTimeZone

Field Detail

accback to summary
private final AccessControlContext acc

Hides org.jboss.logmanager.handlers.PeriodicRotatingFileHandler.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

Constructor Detail

PeriodicSizeRotatingFileHandlerback to summary
public PeriodicSizeRotatingFileHandler()

Default constructor.

PeriodicSizeRotatingFileHandlerback to summary
public PeriodicSizeRotatingFileHandler(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
PeriodicSizeRotatingFileHandlerback to summary
public PeriodicSizeRotatingFileHandler(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
PeriodicSizeRotatingFileHandlerback to summary
public PeriodicSizeRotatingFileHandler(final File file, final String suffix) throws FileNotFoundException

Construct a new instance with the given output file.

Parameters
file:File

the file

suffix:String

the format suffix to use

Exceptions
FileNotFoundException:
if the file could not be found on open
PeriodicSizeRotatingFileHandlerback to summary
public PeriodicSizeRotatingFileHandler(final File file, final String suffix, final boolean append) throws FileNotFoundException

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

Parameters
file:File

the file

suffix:String

the format suffix to use

append:boolean

true to append, false to overwrite

Exceptions
FileNotFoundException:
if the file could not be found on open
PeriodicSizeRotatingFileHandlerback to summary
public PeriodicSizeRotatingFileHandler(final File file, final String suffix, final long rotateSize, final int maxBackupIndex) throws FileNotFoundException

Construct a new instance with the given output file.

Parameters
file:File

the file

suffix:String

the format suffix to use

rotateSize:long

the size the file should rotate at

maxBackupIndex:int

the maximum number of files to backup

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

Construct a new instance with the given output file.

Parameters
file:File

the file

suffix:String

the format suffix to use

rotateSize:long

the size the file should rotate at

maxBackupIndex:int

the maximum number of files to backup

append:boolean

true to append, false to overwrite

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

Method Detail

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.PeriodicRotatingFileHandler.preWrite.

Doc from org.jboss.logmanager.handlers.PeriodicRotatingFileHandler.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. This implementation checks to see if the scheduled rollover time has yet occurred.

Parameters
record:ExtLogRecord

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

the record about to be logged

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

Overrides org.jboss.logmanager.handlers.PeriodicRotatingFileHandler.setFile.

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

Set the output file.

Parameters
file:File

the file

Annotations
@Override
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

Annotations
@Override
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