Package ch.qos.logback.core.rolling
Class RollingFileAppender<E>
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.UnsynchronizedAppenderBase<E>
-
- ch.qos.logback.core.OutputStreamAppender<E>
-
- ch.qos.logback.core.FileAppender<E>
-
- ch.qos.logback.core.rolling.RollingFileAppender<E>
-
- All Implemented Interfaces:
Appender<E>
,ContextAware
,FilterAttachable<E>
,LifeCycle
public class RollingFileAppender<E> extends FileAppender<E>
RollingFileAppender
extendsFileAppender
to backup the log files depending onRollingPolicy
andTriggeringPolicy
. For more information about this appender, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#RollingFileAppender
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
COLLISION_URL
(package private) java.io.File
currentlyActiveFile
private static java.lang.String
RFA_LATE_FILE_URL
private static java.lang.String
RFA_NO_RP_URL
private static java.lang.String
RFA_NO_TP_URL
(package private) RollingPolicy
rollingPolicy
(package private) TriggeringPolicy<E>
triggeringPolicy
-
Fields inherited from class ch.qos.logback.core.FileAppender
append, COLLISION_WITH_EARLIER_APPENDER_URL, DEFAULT_BUFFER_SIZE, fileName
-
Fields inherited from class ch.qos.logback.core.OutputStreamAppender
encoder, lock
-
Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
name, started
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description RollingFileAppender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
attemptOpenFile()
private void
attemptRollover()
private boolean
checkForCollisionsInPreviousRollingFileAppenders()
private boolean
checkForFileAndPatternCollisions()
java.lang.String
getFile()
Returns the value of the File property.RollingPolicy
getRollingPolicy()
TriggeringPolicy<E>
getTriggeringPolicy()
private boolean
innerCheckForFileNamePatternCollisionInPreviousRFA(FileNamePattern fileNamePattern)
void
rollover()
Implemented by delegating most of the rollover work to a rolling policy.void
setFile(java.lang.String file)
The File property takes a string value which should be the name of the file to append to.void
setRollingPolicy(RollingPolicy policy)
Sets the rolling policy.void
setTriggeringPolicy(TriggeringPolicy<E> policy)
void
start()
If the value of File is notnull
, thenFileAppender.openFile(java.lang.String)
is called with the values of File and Append properties.void
stop()
Stop this appender instance.protected void
subAppend(E event)
This method differentiates RollingFileAppender from its super class.-
Methods inherited from class ch.qos.logback.core.FileAppender
addErrorForCollision, checkForFileCollisionInPreviousFileAppenders, isAppend, isPrudent, openFile, rawFileProperty, setAppend, setBufferSize, setPrudent, writeOut
-
Methods inherited from class ch.qos.logback.core.OutputStreamAppender
append, closeOutputStream, getEncoder, getOutputStream, isImmediateFlush, setEncoder, setImmediateFlush, setLayout, setOutputStream
-
Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
-
-
-
Field Detail
-
currentlyActiveFile
java.io.File currentlyActiveFile
-
triggeringPolicy
TriggeringPolicy<E> triggeringPolicy
-
rollingPolicy
RollingPolicy rollingPolicy
-
RFA_NO_TP_URL
private static java.lang.String RFA_NO_TP_URL
-
RFA_NO_RP_URL
private static java.lang.String RFA_NO_RP_URL
-
COLLISION_URL
private static java.lang.String COLLISION_URL
-
RFA_LATE_FILE_URL
private static java.lang.String RFA_LATE_FILE_URL
-
-
Method Detail
-
start
public void start()
Description copied from class:FileAppender
If the value of File is notnull
, thenFileAppender.openFile(java.lang.String)
is called with the values of File and Append properties.- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classFileAppender<E>
-
checkForFileAndPatternCollisions
private boolean checkForFileAndPatternCollisions()
-
checkForCollisionsInPreviousRollingFileAppenders
private boolean checkForCollisionsInPreviousRollingFileAppenders()
-
innerCheckForFileNamePatternCollisionInPreviousRFA
private boolean innerCheckForFileNamePatternCollisionInPreviousRFA(FileNamePattern fileNamePattern)
-
stop
public void stop()
Description copied from class:OutputStreamAppender
Stop this appender instance. The underlying stream or writer is also closed.Stopped appenders cannot be reused.
- Specified by:
stop
in interfaceLifeCycle
- Overrides:
stop
in classFileAppender<E>
-
setFile
public void setFile(java.lang.String file)
Description copied from class:FileAppender
The File property takes a string value which should be the name of the file to append to.- Overrides:
setFile
in classFileAppender<E>
-
getFile
public java.lang.String getFile()
Description copied from class:FileAppender
Returns the value of the File property.This method may be overridden by derived classes.
- Overrides:
getFile
in classFileAppender<E>
-
rollover
public void rollover()
Implemented by delegating most of the rollover work to a rolling policy.
-
attemptOpenFile
private void attemptOpenFile()
-
attemptRollover
private void attemptRollover()
-
subAppend
protected void subAppend(E event)
This method differentiates RollingFileAppender from its super class.- Overrides:
subAppend
in classOutputStreamAppender<E>
-
getRollingPolicy
public RollingPolicy getRollingPolicy()
-
getTriggeringPolicy
public TriggeringPolicy<E> getTriggeringPolicy()
-
setRollingPolicy
public void setRollingPolicy(RollingPolicy policy)
Sets the rolling policy. In case the 'policy' argument also implementsTriggeringPolicy
, then the triggering policy for this appender is automatically set to be the policy argument.- Parameters:
policy
-
-
setTriggeringPolicy
public void setTriggeringPolicy(TriggeringPolicy<E> policy)
-
-