[logback-user] Logback daily rollover and on every server startup

Gaurav Kumar gaurav419 at gmail.com
Tue Nov 6 22:20:52 CET 2012


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:*
*@NoAutoStart
public class LogbackLogTriggeringPolicy<E> extends
DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {
  @Override
      public void start() {
          super.start();
          nextCheck = 0L;
*
*           isTriggeringEvent(null, null);
          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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20121107/4b8cbb5f/attachment.html>


More information about the Logback-user mailing list