序
本文主要研究一下logback的FixedWindowRollingPolicy
RollingPolicy
ch/qos/logback/core/rolling/RollingPolicy.java
/**
* A <code>RollingPolicy</code> is responsible for performing the rolling over
* of the active log file. The <code>RollingPolicy</code> is also responsible
* for providing the <em>active log file</em>, that is the live file where
* logging output will be directed.
*
* @author Ceki Gülcü
*/
public interface RollingPolicy extends LifeCycle {
/**
* Rolls over log files according to implementation policy.
*
* <p>
* This method is invoked by {@link RollingFileAppender}, usually at the behest
* of its {@link TriggeringPolicy}.
*
* @throws RolloverFailure Thrown if the rollover operation fails for any
* reason.
*/
void rollover() throws RolloverFailure;
/**
* Get the name of the active log file.
*
* <p>
* With implementations such as {@link TimeBasedRollingPolicy}, this method
* returns a new file name, where the actual output will be sent.
*
* <p>
* On other implementations, this method might return the FileAppender's file
* property.
*/
String getActiveFileName();
/**
* The compression mode for this policy.
*
* @return
*/
CompressionMode getCompressionMode();
/**
* This method allows RollingPolicy implementations to be aware of their
* containing appender.
*
* @param appender
*/
void setParent(FileAppender<?> appender);
}
RollingPolicy接口定义了rollover、getActiveFileName、getCompressionMode、setParent方法

本文深入剖析了Logback中的FixedWindowRollingPolicy,涉及接口实现、文件重命名与压缩策略。
最低0.47元/天 解锁文章
3111

被折叠的 条评论
为什么被折叠?



