[logback-dev] Compression of log files is omitted when application is stopped at rollover
ch w
skyding228 at gmail.com
Tue Aug 21 15:06:56 CEST 2018
*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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-dev/attachments/20180821/70f3ba6f/attachment.html>
More information about the logback-dev
mailing list