Hi,
With logback, is there a way to do daily Rollover AND also rollover on every server restart?
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?
My setup:
For daily rollover I am using the following pattern:
....
<file>${jetty.home}/logs/testapp.${dateStr}.log</file>
....
<fileNamePattern>${jetty.home}/logs/testapp.%d{yyyy-MM-dd}.log.${timeStr}</fileNamePattern>
where dateStr and timeStr are defined as:
<timestamp key="dateStr" datePattern="yyyy-MM-dd" timeReference="contextBirth"/>
<timestamp key="timeStr" datePattern="HHmmssSSS" timeReference="contextBirth"/>
Also, I have the following triggering policy:
<timeBasedFileNamingAndTriggeringPolicy class="utils.LogbackLogTriggeringPolicy"/>LogbackLogTriggeringPolicy.java is:
@NoAutoStartisTriggeringEvent(null, null);
public class LogbackLogTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {
@Override
public void start() {
super.start();
nextCheck = 0L;
try {
tbrp.rollover();
} catch (RolloverFailure e) {
//Do nothing
}
}
}
With the above LogbackLogTriggeringPolicy I am able to achieve rollover on server startup but daily rollover is not working. Any suggestions?
Thanks!