Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
1.2.3
-
suse linux
Description
- log setting:<appender name="DebugAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${loggerHome}/logs/${moduleName}/debug/${moduleName}_debug.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${loggerHome}/logs/${moduleName}/debug/${moduleName}debug%d{yyyyMMddHH{color}}_%i.log</fileNamePattern>
<maxHistory>2</maxHistory>
<CleanHistoryOnStart>true</CleanHistoryOnStart>
<maxFileSize>100MB</maxFileSize>
</rollingPolicy>
<encoder charset="UTF-8">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}|%-5level|[%thread]|%m%n%</pattern>
</encoder>
</appender>
- after set the CleanhistoryOnStart to true, the history log cann't be deleted base on the rule.
- debugging the code,find the issue :ch.qos.logback.core.rolling.helper.RollingCalendar public long periodBarriersCrossed(long start, long end) {
if (start > end)
throw new IllegalArgumentException("Start cannot come before end");
long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone());
long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone());
long diff = endFloored - startFloored;
switch (periodicityType) {
case TOP_OF_MILLISECOND:
return diff;
case TOP_OF_SECOND:
return diff / MILLIS_IN_ONE_SECOND;
case TOP_OF_MINUTE:
return diff / MILLIS_IN_ONE_MINUTE;
case TOP_OF_HOUR:
return (int) diff / MILLIS_IN_ONE_HOUR;
case TOP_OF_DAY:
return diff / MILLIS_IN_ONE_DAY;
case TOP_OF_WEEK:
return diff / MILLIS_IN_ONE_WEEK;
case TOP_OF_MONTH:
return diffInMonths(start, end);
default:
throw new IllegalStateException("Unknown periodicity type.");
}
}
the red color code will return the number below 0. because covert long to int . the value will be < 0.
It's the reason why we cann't delete the history logs after system start