How to set integer counter format for file name in logback to 3 digits?

Viewed 26

It is possible to set the name of the log file generated by logback so that the archive files are numbered in the following way: Test.2022-09-23.001.log instead of Test.2022-09-23.1.log? It is about the numbering, which is the archive file on a given day, to number 001.002 ... instead of 1, 2 ... "% i" is responsible for this place, there is no mention in the documentation and changing this parameter to another one, and the change to "%iii" causes a compile error and change to "%03i" but does not work. Does anyone know if there is such a possibility? It is a file name given in the fileNamePattern tag

<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>Test.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
      <fileNamePattern>Test.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
       <maxFileSize>100MB</maxFileSize>    
       <maxHistory>60</maxHistory>
       <totalSizeCap>20GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
      <pattern>%msg%n</pattern>
    </encoder>
  </appender>
0 Answers
Related