[logback-user] Rolling with compression with changing logfile name

Jonas Gröger jonas at huntun.de
Sat Apr 14 22:59:54 CEST 2018


So we have a use case where

+ Applications get redeployed frequently (10 per day)
+ The applications run in containers (Openshift)
+ The container hostname is always different on redeploy (new container)
+ The logfile is named after the container hostname (i.e. svc-2-asdf)

Using the RollingFileAppender with a


and a TimeBasedRollingPolicy with a


this works fine when we do not redeploy. On redeploy however the ${HOSTNAME} changes and logs are not compressed because the RollingFileAppender only compresses on roll which is every period (here: minute) if the filename is still in the same pattern, which its not here.

Similarly the <maxHistory> and the <cleanHistoryOnStart> do not work here. For this I have created a RollingFileAppender that compresses on shutdown. You can find it here:


Is there another way without this custom Appender?

-- Jonas

More information about the logback-user mailing list