log4j2是否提供每天滚动文件并在月底归档日志文件的机制?

huangapple go评论74阅读模式
英文:

Does log4j2 provide any mechanism to rollover file every day and archive log files at the end of the month

问题

log4j2是否提供每天滚动文件并在月底存档日志文件的机制?
我能够实现每天滚动,但一个月后,我想压缩所有日志并移到存档文件夹。

英文:

Does log4j2 provide any mechanism to rollover file every day and archive log files at the end of the month?
I am able to achieve daily rollover but after a month I want to compress all logs and move to archive folder

答案1

得分: 0

抱歉,Log4j目前不支持此功能,但创建一个Jira问题来请求此功能将是一个很好的补充。Log4j已经支持在每次滚动时评估操作。目前唯一已实现的Action插件是DeleteAction。但是,Log4j内置了在每次滚动时压缩文件的操作,但这些不是插件,因为它们是在通用操作添加之前创建的。可以相对简单地创建一个CompressAction,通过使用现有的PathConditions或创建新的PathCondition来调用现有的压缩操作。

英文:

No, Log4j doesn't currently support that but it would be great to create a Jira issue for it as it would be a neat addition. Log4j already supports Actions being evaluated on every rollover. The only Action plugin currently implemented is the DeleteAction. But Log4j has built in Actions to compress files on every rollover, but these are not plugins as they were created before generic actions were added. It would be fairly simply to create a CompressAction that invokes the existing compress actions using the existing PathConditions or by creating a new PathCondition.

huangapple
  • 本文由 发表于 2020年8月6日 10:52:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63276153.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定