[logback-user] TimeBasedFileNamingAndTriggeringPolicy writes to many files after restart

Curtis Porter curtis.porter at gmail.com
Mon Jan 23 23:33:40 CET 2012


While doing some testing I've encountered a situation where we generate a
large number of log files.  They seem to be rotating as expected, except
for directly after a restart of the application.  When that happens,
logback writes a few messages to each file, starting at index 101 until it
reaches the current file, at which point it resumes working normally.

For example, the logs should rotate each month, and grow up to 10MB before
rotating.  As each rotates its log index will increase (2012-01.1.log,
2012-01.2.log, ..., 2012-01.891.log).  logback is writing the first few
messages to 2012-01.101.log and then walks up each log after that, writing
a few log messages before moving on (presumably "realizing" that each log
is at its size threshold).

I'm puzzled that it starts at 2012-01.101.log (2012-01.1.log would make
more sense).  It's even more puzzling that it writes anything to the lower
logs in the first place. Any ideas why this is happening?

Here is my configuration:

<configuration debug="false">
  <turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
     <Marker>ALWAYS</Marker>
     <OnMatch>ACCEPT</OnMatch>
   </turboFilter>

  <appender name="R"
class="ch.qos.logback.core.rolling.RollingFileAppender">
    <prudent>true</prudent>
    <encoder>
      <Pattern>%d %p [%t] %X{user} %X{session} %F:%L - %m%n</Pattern>
    </encoder>
    <rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<FileNamePattern>${catalina.home}/logs/tomcat.%d{yyyy-MM}.%i.log</FileNamePattern>
      <TimeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>10MB</maxFileSize>
      </TimeBasedFileNamingAndTriggeringPolicy>
      <maxHistory>2</maxHistory>
    </rollingPolicy>
  </appender>


  <logger name="org.apache.catalina.startup.Catalina" level="INFO" />

  <root level="warn">
    <appender-ref ref="R"/>
  </root>
</configuration>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120123/94da76c5/attachment.html>


More information about the Logback-user mailing list