log4j2 archive every week, rotate every startup?

半城伤御伤魂 提交于 2019-12-11 04:27:19

问题


I am trying to figure out how to simply rename the active log file on every startup, and archive all the rotated files once a week.

I am forced to specify the "filePattern" at the RollingFile appender declaration, instead of at the policy. Do this make sense?


回答1:


I ended up doing my own implementation of a DeleteAction, and attaching it to a DefaultRolloverStrategy, so that it is zipping everything before deleting. You can find the sourcecode at:

https://github.com/lqbweb/log4j2-ZipDelete



来源:https://stackoverflow.com/questions/37841870/log4j2-archive-every-week-rotate-every-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!