java Logback,设置每天最大历史文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7934829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 22:05:02  来源:igfitidea点击:

Logback, set max history files per day

javalogginglogbackrolloverlog-rotation

提问by Prasanna

I use TimeBasedRollingPolicyand SizeAndTimeBasedFNATPtriggering policy for my logback configuration. The rollover of log files is set to happen every day and it will also be triggered if log file size goes beyond a limit.

我为我的 logback 配置使用TimeBasedRollingPolicySizeAndTimeBasedFNATP触发策略。日志文件的翻转设置为每天发生,如果日志文件大小超出限制也会触发。

If I do setMaxHistory(10) on TimeBasedRollingPolicywith a daily roll over, then it will archive all log files in last 10 days. But what I want is to set maxHIstory on SizeAndTimeBasedFNATP each day.

如果我TimeBasedRollingPolicy每天滚动更新 setMaxHistory(10) ,那么它将存档过去 10 天内的所有日志文件。但我想要的是每天在 SizeAndTimeBasedFNATP 上设置 maxHIstory。

Is this possible with logback?

这可以通过 logback 实现吗?

回答by Ceki

With SizeAndTimeBasedFNATP and MaxHistory set to 10, the logs older than 10 days will be removed (assuming daily rollover schedule). Size is not factored in the into removal logic.

将 SizeAndTimeBasedFNATP 和 MaxHistory 设置为 10,将删除超过 10 天的日志(假设每天滚动计划)。大小不计入删除逻辑。