<div dir="ltr">Hi,<br><br>With logback, is there a way to do daily Rollover AND also rollover on every server restart? <br>I also wanted rollover based on Size, but I have seen an issue already reported about this being a bug. If not, what is the best way to do this?<br>
<br><br>My setup:<br>For daily rollover I am using the following pattern: <br><i> ....<br><file>${jetty.home}/logs/testapp.${dateStr}.log</file><br>....<br></i><i><fileNamePattern>${jetty.home}/logs/testapp.%d{yyyy-MM-dd}.log.${timeStr}</fileNamePattern><br>
<br>where dateStr and timeStr are defined as:<br></i><br><br><i><i><timestamp key="dateStr" datePattern="yyyy-MM-dd" timeReference="contextBirth"/><br></i><timestamp key="timeStr" datePattern="HHmmssSSS" timeReference="contextBirth"/><br>
<br><br>Also, I have the following triggering policy:</i><br><i><i><timeBasedFileNamingAndTriggeringPolicy class="utils.<b>LogbackLogTriggeringPolicy</b>"/></i><br><br></i><p><b>LogbackLogTriggeringPolicy.java is:</b></p>
<div class="im"><i>@NoAutoStart<br>public class LogbackLogTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {<br> @Override<br> public void start() {<br> super.start();<br>
nextCheck = 0L;<br></i></div><i>
isTriggeringEvent(null, null);<br> try {<br> tbrp.rollover();<br> } catch (RolloverFailure e) {<br> //Do nothing<br> }<br>
}<br>}<br><br><br>With the above </i>LogbackLogTriggeringPolicy I am able to achieve rollover on server startup but daily rollover is not working. Any suggestions?<br><br>Thanks!<br></div>