I want to hold up to 20 log files, where I rollback when a file reaches a certain size. The catch is - when I archive a file I want to to have the current time in its' name.
Currently I use:
<timestamp key="bySecond" datePattern="ddMMyyyy'-'HHmmss" timeReference="contextBirth"/>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${application.home}/logs/log.txt</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${application.home}/logs/${bySecond}.%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>30</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>2KB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date [%level] [%thread] from %logger - %message%n%xException</pattern>
</encoder>
</appender>
But the problem here is the bySecond
timestamp is evaluated only once at service start-up.
What I want is the current time for each rollover. How can I achieve this?
BTW, If i could get rid of the necessity to use the %i in the file name, it would be great!