Reputation: 2190
I have below rolling policy in the logback.xml.
Problem is, if file size grows beyond 10 MB , it's throwing exception.
Looks like it is trying to create a new file but since the same file is already present for the same date, it's not able to do that and throws exception.
For example , we already have a file pvExport.2016-05-15.log and if pvExport.log grows beyond 10 MB, it would try to create the file with the same name as pvExport.2016-05-15.log, and hence would throw exception, not sure though
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${EXPORT_LOG_HOME}/pvExport.%d{yyyy-MM-dd}.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
Upvotes: 2
Views: 226
Reputation: 2566
Your fileNamePattern
is actually invalid in this case. From the docs
Note the "%i" conversion token in addition to "%d". Both the %i and %d tokens are mandatory. Each time the current log file reaches maxFileSize before the current time period ends, it will be archived with an increasing index, starting at 0.
Adding the %i
conversion token to your pattern should fix this:
<fileNamePattern>${EXPORT_LOG_HOME}/pvExport.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
Upvotes: 2