public class TimeBasedRollingPolicy<E> extends RollingPolicyBase implements TriggeringPolicy<E>
TimeBasedRollingPolicy
is both easy to configure and quite
powerful. It allows the roll over to be made based on time. It is possible to
specify that the roll over 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
Constructor and Description |
---|
TimeBasedRollingPolicy() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getActiveFileName()
The active log file is determined by the value of the parent's filename
option.
|
int |
getMaxHistory()
Get the number of archive files to keep.
|
TimeBasedFileNamingAndTriggeringPolicy<E> |
getTimeBasedFileNamingAndTriggeringPolicy() |
boolean |
isCleanHistoryOnStart() |
boolean |
isTriggeringEvent(java.io.File activeFile,
E event)
Should roll-over be triggered at this time?
|
void |
rollover()
Rolls over log files according to implementation policy.
|
void |
setCleanHistoryOnStart(boolean cleanHistoryOnStart)
Should archive removal be attempted on application start up? Default is false.
|
void |
setMaxHistory(int maxHistory)
Set the maximum number of archive files to keep.
|
void |
setTimeBasedFileNamingAndTriggeringPolicy(TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedTriggering) |
void |
setTotalSizeCap(FileSize totalSizeCap) |
void |
start() |
void |
stop() |
java.lang.String |
toString() |
getCompressionMode, getFileNamePattern, getParentsRawFileProperty, isParentPrudent, isStarted, setFileNamePattern, setParent
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getStatusManager, setContext
public void start()
start
in interface LifeCycle
start
in class RollingPolicyBase
public void stop()
stop
in interface LifeCycle
stop
in class RollingPolicyBase
public void setTimeBasedFileNamingAndTriggeringPolicy(TimeBasedFileNamingAndTriggeringPolicy<E> timeBasedTriggering)
public TimeBasedFileNamingAndTriggeringPolicy<E> getTimeBasedFileNamingAndTriggeringPolicy()
public void rollover() throws RolloverFailure
RollingPolicy
This method is invoked by RollingFileAppender
, usually at the
behest of its TriggeringPolicy
.
rollover
in interface RollingPolicy
RolloverFailure
- Thrown if the rollover operation fails for any reason.public java.lang.String getActiveFileName()
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.
getActiveFileName
in interface RollingPolicy
public boolean isTriggeringEvent(java.io.File activeFile, E event)
TriggeringPolicy
isTriggeringEvent
in interface TriggeringPolicy<E>
activeFile
- A reference to the currently active log file.event
- A reference to the currently event.public int getMaxHistory()
public void setMaxHistory(int maxHistory)
maxHistory
- number of archive files to keeppublic boolean isCleanHistoryOnStart()
public void setCleanHistoryOnStart(boolean cleanHistoryOnStart)
cleanHistoryOnStart
- public java.lang.String toString()
toString
in class java.lang.Object
public void setTotalSizeCap(FileSize totalSizeCap)
Copyright © 2010 - 2020 Adobe. All Rights Reserved