- All Implemented Interfaces:
RollingPolicy,TriggeringPolicy<E>,ContextAware,LifeCycle
- Direct Known Subclasses:
SizeAndTimeBasedRollingPolicy
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
FieldsFields inherited from class ch.qos.logback.core.rolling.RollingPolicyBase
compressionMode, fileNamePatternStrFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe active log file is determined by the value of the parent's filename option.Return theLengthCounterinstance associated with this triggering policy.intGet the number of archive files to keep.booleanbooleanisTriggeringEvent(File activeFile, E event) Delegates to the underlying timeBasedFileNamingAndTriggeringPolicy.protected booleanvoidrollover()Rolls over log files according to implementation policy.voidsetCleanHistoryOnStart(boolean cleanHistoryOnStart) Should archive removal be attempted on application start up? Default is false.voidsetMaxHistory(int maxHistory) Set the maximum number of archive files to keep.voidsetTimeBasedFileNamingAndTriggeringPolicy(TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedTriggering) voidsetTotalSizeCap(FileSize totalSizeCap) voidstart()voidstop()toString()Methods inherited from class ch.qos.logback.core.rolling.RollingPolicyBase
determineCompressionMode, getCompressionMode, getFileNamePattern, getParentsRawFileProperty, isParentPrudent, isStarted, setFileNamePattern, setParentMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Field Details
-
totalSizeCap
-
-
Constructor Details
-
TimeBasedRollingPolicy
public TimeBasedRollingPolicy()
-
-
Method Details
-
start
- Specified by:
startin interfaceLifeCycle- Overrides:
startin classRollingPolicyBase
-
isUnboundedTotalSizeCap
-
stop
- Specified by:
stopin interfaceLifeCycle- Overrides:
stopin classRollingPolicyBase
-
setTimeBasedFileNamingAndTriggeringPolicy
public void setTimeBasedFileNamingAndTriggeringPolicy(TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedTriggering) -
getTimeBasedFileNamingAndTriggeringPolicy
-
rollover
Description copied from interface:RollingPolicyRolls over log files according to implementation policy.This method is invoked by
RollingFileAppender, usually at the behest of itsTriggeringPolicy.- Specified by:
rolloverin interfaceRollingPolicy- Throws:
RolloverFailure- Thrown if the rollover operation fails for any reason.
-
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.
- Specified by:
getActiveFileNamein interfaceRollingPolicy
-
isTriggeringEvent
Delegates to the underlying timeBasedFileNamingAndTriggeringPolicy.- Specified by:
isTriggeringEventin interfaceTriggeringPolicy<E>- Parameters:
activeFile- A reference to the currently active log file.event- A reference to the current event.- Returns:
-
getLengthCounter
Description copied from interface:TriggeringPolicyReturn theLengthCounterinstance associated with this triggering policy. The returned value may be null.- Specified by:
getLengthCounterin interfaceTriggeringPolicy<E>- Returns:
- a LengthCounter instance, may be null
-
getMaxHistory
Get the number of archive files to keep.- Returns:
- number of archive files to keep
-
setMaxHistory
Set the maximum number of archive files to keep.- Parameters:
maxHistory- number of archive files to keep
-
isCleanHistoryOnStart
-
setCleanHistoryOnStart
Should archive removal be attempted on application start up? Default is false.- Parameters:
cleanHistoryOnStart-- Since:
- 1.0.1
-
toString
-
setTotalSizeCap
-