我有一个在几台服务器上运行的应用程序,这些服务器已经使用一个使用 logback 的 java 应用程序运行了几个月。结果我们忘记了限制历史记录的大小。
我配置了以下参数:
- maxHistory: 10
- cleanHistoryOnStart: true
我重新部署了该应用程序,但是当它启动时,文件仍然存在并且没有被删除。
这个配置不应该确保在启动时删除文件吗?这样做的方法是什么?
最佳答案
这是一个老问题,但如果其他人对此有疑问,以下是可能发生的一些可能原因:
maxHistory
值(value)意味着意想不到的事情。来自 Logback
documentation :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.
cleanHistoryOnStart
在 1.0.1 在最后 3 种情况下,应该在某处记录错误,阅读:
Logback file error : no applicable action for [cleanHistoryOnStart], current pattern is [...]
如果您不确定自己检查的位置是否正确,请故意拼错并寻找日志。然后更正拼写错误并检查错误是否仍然存在(这次是因为它无效)。
关于logging - Logback - cleanHistoryOnStart 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43635725/