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

public Class PeriodicRotatingFileHandler

extends FileHandler
Class Inheritance
Known Direct Subclasses
org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler
Imports
java.io.File, .FileNotFoundException, .IOException, .UncheckedIOException, java.security.AccessControlContext, .AccessController, .PrivilegedAction, java.time.Instant, .ZonedDateTime, java.time.format.DateTimeFormatter, java.time.temporal.ChronoField, .ChronoUnit, java.util.TimeZone, java.util.logging.ErrorManager, org.jboss.logmanager.ExtLogRecord

A file handler which rotates the log at a preset time interval. The interval is determined by the content of the suffix string which is passed in to setSuffix(String).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
PeriodicRotatingFileHandler.Period

Possible period values.

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 DateTimeFormatter
private Instant
private String
private PeriodicRotatingFileHandler.Period
private SuffixRotator
private TimeZone

Constructor Summary

AccessConstructor and Description
public
PeriodicRotatingFileHandler()

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

public
PeriodicRotatingFileHandler(final String
the file name
fileName
)

Construct a new instance with the given output file.

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

Construct a new instance with the given output file.

public
PeriodicRotatingFileHandler(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.

Method Summary

Modifier and TypeMethod and Description
private void
calcNextRollover(final Instant fromTime)

protected final String

Returns:

the suffix to be used
getNextSuffix
()

Returns the suffix to be used.

pack-priv SuffixRotator

Returns:

the file rotator
getSuffixRotator
()

Returns the file rotator for this handler.

public TimeZone

Returns:

the configured time zone
getTimeZone
()

Get the configured time zone for this handler.

private static <T extends Comparable<? super T>> T
min(T a, T b)

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.

private void
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)

public void
setSuffix(String
the suffix
suffix
)

Set the suffix string.

public void
setTimeZone(final TimeZone
the configured time zone
timeZone
)

Set the configured time zone for this handler.

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.

formatback to summary
private DateTimeFormatter format
nextRolloverback to summary
private Instant nextRollover
nextSuffixback to summary
private String nextSuffix
periodback to summary
private PeriodicRotatingFileHandler.Period period
suffixRotatorback to summary
private SuffixRotator suffixRotator
timeZoneback to summary
private TimeZone timeZone

Constructor Detail

PeriodicRotatingFileHandlerback to summary
public PeriodicRotatingFileHandler()

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

PeriodicRotatingFileHandlerback to summary
public PeriodicRotatingFileHandler(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
PeriodicRotatingFileHandlerback to summary
public PeriodicRotatingFileHandler(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
PeriodicRotatingFileHandlerback to summary
public PeriodicRotatingFileHandler(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
PeriodicRotatingFileHandlerback to summary
public PeriodicRotatingFileHandler(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

Method Detail

calcNextRolloverback to summary
private void calcNextRollover(final Instant fromTime)
getNextSuffixback to summary
protected final String getNextSuffix()

Returns the suffix to be used.

Returns:String

the suffix to be used

getSuffixRotatorback to summary
pack-priv SuffixRotator getSuffixRotator()

Returns the file rotator for this handler.

Returns:SuffixRotator

the file rotator

getTimeZoneback to summary
public TimeZone getTimeZone()

Get the configured time zone for this handler.

Returns:TimeZone

the configured time zone

minback to summary
private static <T extends Comparable<? super T>> T min(T a, T b)
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. This implementation checks to see if the scheduled rollover time has yet occurred.

Parameters
record:ExtLogRecord

the record about to be logged

rollOverback to summary
private void rollOver()
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

Annotations
@Override
Exceptions
FileNotFoundException:
if an error occurs opening the file
setFileInternalback to summary
private void setFileInternal(final File file) throws FileNotFoundException
setSuffixback to summary
public void setSuffix(String suffix) throws IllegalArgumentException

Set the suffix string. The string is in a format which can be understood by DateTimeFormatter. The period of the rotation is automatically calculated based on the suffix.

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

Parameters
suffix:String

the suffix

Exceptions
IllegalArgumentException:
if the suffix is not valid
setTimeZoneback to summary
public void setTimeZone(final TimeZone timeZone)

Set the configured time zone for this handler.

Parameters
timeZone:TimeZone

the configured time zone

org.jboss.logmanager.handlers back to summary

public final Enum PeriodicRotatingFileHandler.Period

extends Enum<PeriodicRotatingFileHandler.Period>
Class Inheritance

Possible period values. Keep in strictly ascending order of magnitude.

Field Summary

Modifier and TypeField and Description
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period
public static final PeriodicRotatingFileHandler.Period

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PeriodicRotatingFileHandler.Period
public static PeriodicRotatingFileHandler.Period[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DAYback to summary
public static final PeriodicRotatingFileHandler.Period DAY
HALF_DAYback to summary
public static final PeriodicRotatingFileHandler.Period HALF_DAY
HOURback to summary
public static final PeriodicRotatingFileHandler.Period HOUR
MINUTEback to summary
public static final PeriodicRotatingFileHandler.Period MINUTE
MONTHback to summary
public static final PeriodicRotatingFileHandler.Period MONTH
NEVERback to summary
public static final PeriodicRotatingFileHandler.Period NEVER
WEEKback to summary
public static final PeriodicRotatingFileHandler.Period WEEK
YEARback to summary
public static final PeriodicRotatingFileHandler.Period YEAR

Constructor Detail

Periodback to summary
private Period()

Method Detail

valueOfback to summary
public static PeriodicRotatingFileHandler.Period valueOf(String name)
valuesback to summary
public static PeriodicRotatingFileHandler.Period[] values()