log4j2 archive every week, rotate every startup?

2019-07-25 00:03发布

问题:

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