Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-185

Simultaneous support of %d and %i

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • logback-core
    • None

    Description

      Hello Neil,

      FileNamePattern does not support the %d when used within FixedWindowRollingPolicy. Only %i is supported. It's a currentlimitation of the code.

      I suggest that you enter a jira issue requesting simultaneous support for %d and %i. Referencing or copying this thread would set a context for the problem which would be helpful.

      Cheers,

      Neil Lott wrote:
      Hi,
      I'm using a FileNamePattern with a FixedWindowPolicy:
      Here's my appender:
      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>/usr/local/mystro/logs/MSAServer.log</file>
      <append>true</append>
      <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <FileNamePattern>/usr/local/neil/logs/MSAServer.%i.%d

      {yyyyMMdd-HHmmss}

      .gz</FileNamePattern> <MinIndex>1</MinIndex>
      <MaxIndex>3</MaxIndex>
      </rollingPolicy>
      <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <MaxFileSize>1KB</MaxFileSize>
      </triggeringPolicy>
      <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%d

      {ISO8601}

      %-5level [%thread] (%logger

      {0}

      .%M:%L
      ) - %msg%n</Pattern>
      </layout>
      </appender>
      Here's the exception when the file rolls – I had to alter the rollover method of FixedWindowPolicy in order to catch throwable to see what was going on:
      java.lang.IllegalArgumentException: Cannot convert 3 of typejava.lang.Integer
      at ch.qos.logback.core.rolling.helper.DateTokenConverter.convert(DateTokenConverter.java:60)
      [snip]

      Is this an intentional restriction to make the file name pattern have %i first and then %d?
      Thanks,
      Neil

      Attachments

        Activity

          People

            logback-dev Logback dev list
            neillott Neil Lott
            Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: