聊聊logback的FixedWindowRollingPolicy

本文深入剖析了Logback中的FixedWindowRollingPolicy,涉及接口实现、文件重命名与压缩策略。

本文主要研究一下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&uuml;lc&uuml;
 */
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方法

RollingPolicyBase

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值