Hi everyone,
I’m using the configuration below for the appender. What I want to do is rollout the file after reach a size or in a daily bases.
My problem is regarding how many files I want to have. I use the maxHistory and it works well for daily log and remove the old ones.
The problem is when the file achieve the maximum size for it in the same day. It creates a new file with the index number on the file name but I can’t control how many files I can have.
I tried to use the max and min index it inside timeBasedFileNamingAndTriggeringPolicy tag but when the config load it shows na error saying the configuration is in the wrong place.
Even if I put the maxhistory inside this tag it shows the same problem and don’t rollout by size.
<appender name="APPLICATION" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${destination}/${contextName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- separa o arquivo de log diariamente -->
<fileNamePattern>${destination}/${contextName}-%d{yyyyMMdd}.%i.log.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- ou sempre que o arquivo alcancar 100Mb -->
<maxFileSize>1MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>2</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date{yyyyMMdd|HHmmss.SSS}|%-5level|%10X{tid}|%logger{0}:%line|%msg%n</pattern>
</encoder>
</appender>
Any advice will be welcome.
Thank you!
Lucas