Compression of log files is omitted when application is stopped at rollover

*Description:* There is a bug report <https://jira.qos.ch/browse/LOGBACK-914> 4 years ago. It's not fixed yet. It occurs to me now. This is my configuration:
<rollingPolicy class="ch.qos.logback.core.rolling.MyTimeBasedRollingPolicy">
<fileNamePattern>${baseLogPath}/logs/app.%d{yyyy-MM-dd}.log.gz</fileNamePattern> </rollingPolicy>
The log file will roll and compress at midnight normally. but, the compression is omitted if the application is not running at rolling time . The application will restart manually at next day , but the elapsed log file will not be compressed. *Solution:* I have an idea and have put it into practice to fix this problem. I add a property, say compressElapsedPeriodFileOnStart , to TimeBasedRollingPolicy ,default true. It compress the elapsed period log file, as below : 1 calculate the rolling period 2. generate the elapsed period log file name 3. compress it It works well for me, there is a better way ? I will push a PR if no.
participants (1)
-
ch w