[logback-user] Choosing the right triggering and rolling policy

manoj mathai manojpmathai at gmail.com
Mon Aug 1 11:59:15 CEST 2011


Hi,

I am new to logback. I am trying to configure the time and rolling policy
for a rolling file  appender.

Here's what I need:

a) Every "x" minutes, I want it to roll the file regardless of how small the
size of the live file is.(low logging rate)
b) If within those "x" minutes, the live log file size exceeds "y" KBs, i
want it to use indices like ${date_time}.0.log and ${date_time}.1.log and so
on. ( high logging rate)

I'd like "x" to be 15 mins, but if that's not doable, I can live with "x = 1
minute".

Here's my config, which doesn't seem to do exactly what I've described:

<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
  <file>${user.home}/impression_logs/impressions.log</file>
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<fileNamePattern>${user.home}/impression_log_archives/${HOSTNAME}/impressions.%d{yyyy-MM-dd-hh-mm}.%i.log</fileNamePattern>
      <timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
          <maxFileSize>1MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
  </rollingPolicy>

  <encoder>
    <pattern>%msg%n</pattern>
  </encoder>
</appender>

Can some one help me with this ?

-- Manoj M
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20110801/efec7b9a/attachment.html>


More information about the Logback-user mailing list