[logback-user] How to make RollingFileAppender roll even if no log events

David Rosenstrauch darose at darose.net
Fri Aug 2 06:50:21 CEST 2013


Hi.  We're trying to integrate the logback framework into our app, but 
we're running into an issue with RollingFileAppender.

Our app is creating log files.  We are then using RollingFileAppender to 
periodically roll the log file, gzip it, and move it to another 
directory (where it subsequently gets pushed to another server for 
processing).

This all works fine ... as long as there's logging events happening. 
However, when there's no log events, the log file never rolls - which 
prevents it from getting moved to the other directory, and getting 
pushed to the other server.  So in effect, any data in the log file 
stays there and never gets processed.

This takes on particular importance when we want to shut a server down. 
  What should happen is that we stop sending the server traffic, wait 
till the log file rolls, and then gets pushed to the processing server - 
after which it's safe to shut the machine down and be assured of no log 
data loss.

But when we stop sending the server traffic, logback stops rolling the 
log too - resulting in a situation where the log data just sits in the 
original log file and never gets rolled, pushed, and processed.  So 
there's no safe time to shut the server down without loss of log data.


Is there any way out of this situation?  I.e., any way to force logback 
to do actual clock-based rolling, rather than event-based?

Thanks,

DR


More information about the Logback-user mailing list