Hi All,

I have tried to create logfile with respect to below requirment.

1.Create 2 files in which should be have size 100 KB.
2.If size of the 2nd file reaches 100 KB then it should be delete oldest
file and then write the new file.

And i have configured like below.

<appender name="APP_FILE" class="ch.qos.logback.core.
rolling.RollingFileAppender">
      <rollingPolicy class="ch.qos.logback.core.rolling.
TimeBasedRollingPolicy">
        <fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}
/logfile_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.
rolling.SizeAndTimeBasedFNATP">
          <maxFileSize>100KB</maxFileSize>
          <maxHistory>2</maxHistory>
        </timeBasedFileNamingAndTriggeringPolicy>
      </rollingPolicy>
      <encoder>
        <pattern>%d{yyyy-MM-dd}T%d{HH:mm:ss.SSS} %msg%n</pattern>
      </encoder>
    </appender>

With help of above configuration i can create logfile with size 100 KB but
maxHistory not worked.It always create new file if size exceeds 100KB.

I am using logback-core 1.2.3.

Can anyone help me to achieve my requirment?

Am i missed anythink?

Thanks,
prabhu
_______________________________________________
logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to