Top Description Fields Constructors Methods
ch.qos.logback.core.rolling

public Class TimeBasedRollingPolicy<E>

extends RollingPolicyBase
implements TriggeringPolicy<E>
Class Inheritance
All Implemented Interfaces
ch.qos.logback.core.rolling.TriggeringPolicy, ch.qos.logback.core.spi.LifeCycle
Known Direct Subclasses
ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy
Static Imports
ch.qos.logback.core.CoreConstants.UNBOUNDED_HISTORY, .CoreConstants.UNBOUNDED_TOTAL_SIZE_CAP

TimeBasedRollingPolicy is both easy to configure and quite powerful. It allows the rollover to be made based on time. It is possible to specify that the rollover occur once per day, per week or per month.

For more information, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy

Author
Ceki Gülcü

Field Summary

Modifier and TypeField and Description
private ArchiveRemover
pack-priv boolean
pack-priv Future<?>
pack-priv Future<?>
private Compressor
pack-priv FileNamePattern
pack-priv static final String
private int
private RenameUtil
pack-priv TimeBasedFileNamingAndTriggeringPolicy<E>
protected FileSize
Inherited from ch.qos.logback.core.rolling.RollingPolicyBase:
compressionModefileNamePatternfileNamePatternStrzipEntryFileNamePattern

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getActiveFileName()

Implements ch.qos.logback.core.rolling.RollingPolicy.getActiveFileName.

The active log file is determined by the value of the parent's filename option.
public int

Returns:

number of archive files to keep
getMaxHistory
()

Get the number of archive files to keep.

public TimeBasedFileNamingAndTriggeringPolicy<E>
public boolean
public boolean
isTriggeringEvent(File
A reference to the currently active log file.
activeFile
,
final E
A reference to the current event.
event
)

Implements ch.qos.logback.core.rolling.TriggeringPolicy.isTriggeringEvent.

Delegates to the underlying timeBasedFileNamingAndTriggeringPolicy.
protected boolean
pack-priv Future<?>
renameRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName)

public void
rollover()

Implements ch.qos.logback.core.rolling.RollingPolicy.rollover.

Rolls over log files according to implementation policy.
public void
setCleanHistoryOnStart(boolean cleanHistoryOnStart)

Should archive removal be attempted on application start up?

public void
setMaxHistory(int
number of archive files to keep
maxHistory
)

Set the maximum number of archive files to keep.

public void
public void
setTotalSizeCap(FileSize totalSizeCap)

public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private String
private void
waitForAsynchronousJobToStop(Future<?> aFuture, String jobDescription)

Inherited from ch.qos.logback.core.rolling.RollingPolicyBase:
determineCompressionModegetCompressionModegetFileNamePatterngetParentsRawFilePropertyisParentPrudentisStartedsetFileNamePatternsetParent

Field Detail

archiveRemoverback to summary
private ArchiveRemover archiveRemover
cleanHistoryOnStartback to summary
pack-priv boolean cleanHistoryOnStart
cleanUpFutureback to summary
pack-priv Future<?> cleanUpFuture
compressionFutureback to summary
pack-priv Future<?> compressionFuture
compressorback to summary
private Compressor compressor
fileNamePatternWithoutCompSuffixback to summary
pack-priv FileNamePattern fileNamePatternWithoutCompSuffix
FNP_NOT_SETback to summary
pack-priv static final String FNP_NOT_SET
maxHistoryback to summary
private int maxHistory
renameUtilback to summary
private RenameUtil renameUtil
timeBasedFileNamingAndTriggeringPolicyback to summary
pack-priv TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedFileNamingAndTriggeringPolicy
totalSizeCapback to summary
protected FileSize totalSizeCap

Constructor Detail

TimeBasedRollingPolicyback to summary
public TimeBasedRollingPolicy()

Method Detail

getActiveFileNameback to summary
public String getActiveFileName()

Implements ch.qos.logback.core.rolling.RollingPolicy.getActiveFileName.

The active log file is determined by the value of the parent's filename option. However, in case the file name is left blank, then, the active log file equals the file name for the current period as computed by the FileNamePattern option.

The RollingPolicy must know whether it is responsible for changing the name of the active file or not. If the active file name is set by the user via the configuration file, then the RollingPolicy must let it like it is. If the user does not specify an active file name, then the RollingPolicy generates one.

To be sure that the file name used by the parent class has been generated by the RollingPolicy and not specified by the user, we keep track of the last generated name object and compare its reference to the parent file name. If they match, then the RollingPolicy knows it's responsible for the change of the file name.

getMaxHistoryback to summary
public int getMaxHistory()

Get the number of archive files to keep.

Returns:int

number of archive files to keep

getTimeBasedFileNamingAndTriggeringPolicyback to summary
public TimeBasedFileNamingAndTriggeringPolicy<E> getTimeBasedFileNamingAndTriggeringPolicy()
isCleanHistoryOnStartback to summary
public boolean isCleanHistoryOnStart()
isTriggeringEventback to summary
public boolean isTriggeringEvent(File activeFile, final E event)

Implements ch.qos.logback.core.rolling.TriggeringPolicy.isTriggeringEvent.

Delegates to the underlying timeBasedFileNamingAndTriggeringPolicy.

Parameters
activeFile:File

A reference to the currently active log file.

event:E

A reference to the current event.

isUnboundedTotalSizeCapback to summary
protected boolean isUnboundedTotalSizeCap()
renameRawAndAsyncCompressback to summary
pack-priv Future<?> renameRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName) throws RolloverFailure
rolloverback to summary
public void rollover() throws RolloverFailure

Implements ch.qos.logback.core.rolling.RollingPolicy.rollover.

Doc from ch.qos.logback.core.rolling.RollingPolicy.rollover.

Rolls over log files according to implementation policy.

This method is invoked by RollingFileAppender, usually at the behest of its TriggeringPolicy.

Exceptions
RolloverFailure:
Thrown if the rollover operation fails for any reason.
setCleanHistoryOnStartback to summary
public void setCleanHistoryOnStart(boolean cleanHistoryOnStart)

Should archive removal be attempted on application start up? Default is false.

Since
1.0.1
setMaxHistoryback to summary
public void setMaxHistory(int maxHistory)

Set the maximum number of archive files to keep.

Parameters
maxHistory:int

number of archive files to keep

setTimeBasedFileNamingAndTriggeringPolicyback to summary
public void setTimeBasedFileNamingAndTriggeringPolicy(TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedTriggering)
setTotalSizeCapback to summary
public void setTotalSizeCap(FileSize totalSizeCap)
startback to summary
public void start()

Overrides ch.qos.logback.core.rolling.RollingPolicyBase.start.

Implements ch.qos.logback.core.spi.LifeCycle.start.

stopback to summary
public void stop()

Overrides ch.qos.logback.core.rolling.RollingPolicyBase.stop.

Implements ch.qos.logback.core.spi.LifeCycle.stop.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
transformFileNamePattern2ZipEntryback to summary
private String transformFileNamePattern2ZipEntry(String fileNamePatternStr)
waitForAsynchronousJobToStopback to summary
private void waitForAsynchronousJobToStop(Future<?> aFuture, String jobDescription)