当前位置:   article > 正文

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

logback中 maxhistory 无法清理

今天看到同事在群里讨论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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/163278
推荐阅读
相关标签
  

闽ICP备14008679号