Search code examples
configurationrotationlog4jarchivelog4j2

log4j2 archive every week, rotate every startup?


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?


Solution

  • 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