appender - How to finalize log file just after time is over when using logback SizeAndTimeBasedFNATP? -


my object size(10m) , time(daily) based compressed(zip) archiving, write config this:

<appender name="behavior"  class="ch.qos.logback.core.rolling.rollingfileappender">     <encoding>utf-8</encoding>     <rollingpolicy class="ch.qos.logback.core.rolling.timebasedrollingpolicy">         <filenamepattern>${log_home}/%d{yyyy-mm-dd}.%i.log.zip</filenamepattern>         <timebasedfilenamingandtriggeringpolicy class="ch.qos.logback.core.rolling.sizeandtimebasedfnatp">             <maxfilesize>10mb</maxfilesize>          </timebasedfilenamingandtriggeringpolicy>     </rollingpolicy>     <layout class="ch.qos.logback.classic.patternlayout">         <pattern>%d{yyyy-mm-dd hh:mm:ss.sss} %logger{50} - %msg%n         </pattern>    </layout> </appender> 

but meet problem. example, today aug 10th, logback writing log file "2013-08-10.0.log".

but log file won't finalized(it means closed , compressed "2013-08-10.0.log.zip") @ aug 11st 0:00:00. in fact, won't finalized until first record after aug 10th written.

this means, after aug 10th, if first record written @ aug 11st 16:00:00, can't "2013-08-10.0.log.zip" when scan directory between aug 11st 0:00:00 , 16:00:00. can "2013-08-10.0.log" , can't make sure if finished.

how can finalize log file time over?

according logback-manual, rollover triggered on first log-event after rollover time, not time itself:

"for various technical reasons, rollovers not clock-driven depend on arrival of logging events. example, on 8th of march 2002, assuming filenamepattern set yyyy-mm-dd (daily rollover), arrival of first event after midnight trigger rollover. if there no logging events during, 23 minutes , 47 seconds after midnight, rollover occur @ 00:23'47 on march 9th , not @ 0:00 am. thus, depending on arrival rate of events, rollovers might triggered latency." (http://logback.qos.ch/manual/appenders.html)

so there no configuration-only way achieve intend. if it's issue, perhaps try implement code in application sends logging-event right after midnight make sure rollover triggered in timely fashion. if have no access main application's code, implement simple little application clocks , sends 1 logging-event after midnight every day , uses same appender.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -