英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论