日志分析里面的max是什么_logback 日志清理maxHistory 配置分析

今天看到同事在群里讨论logback日志清理的配置,主要是maxHistory配置后实际清理的周期问题。官网的解释如下:The optional maxHistory property controls the maximum number of archive files to keep, asynchronously deleting older files. For example, if ...
摘要由CSDN通过智能技术生成

今天看到同事在群里讨论logback日志清理的配置,主要是maxHistory配置后实际清理的周期问题。官网的解释如下:The optional maxHistory property controls the maximum number of archive files to keep, asynchronously deleting older files. For example, if you specify monthly rollover, and set maxHistory to 6, then 6 months worth of archives files will be kept with files older than 6 months deleted. Note as old archived log files are removed, any folders which were created for the purpose of log file archiving will be removed as appropriate.

可以发现实际上执行的周期是和roll的周期有关,出于好奇确定看一下源码是怎样实现的。

项目使用的是 ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy

public void start() {

SizeAndTimeBasedFNATP sizeAndTimeBasedFNATP = new SizeAndTimeBasedFNATP(Usage.EMBEDDED);

if(maxFileSize == null) {

addError("maxFileSize property is mandatory.");

return;

} else {

addInfo("Archive files will be limited to ["+maxFileSize+"] each.");

}

sizeAndTimeBasedFNATP.setMaxFileSize(maxFileSize);

timeBasedFileNamingAndTriggeringPolicy = sizeAndTimeBasedFNATP;

if(!isUnboundedTotalSizeCap() && totalSizeCap.getSize() < maxFileSize.getSize()) {

addError("totalSizeCap of ["+totalSizeCap+"] is smaller than maxFileSize ["+maxFileSize+"] which is non-sensical");

return;

}

// most work is done by the parent super.start();

}

我想找的处理逻辑在super.start()

public void start() {

// set the LR for our utility object renameUtil.setContext(this.context)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值