Details
-
Improvement
-
Resolution: Unresolved
-
Major
-
None
-
1.2.9
-
None
-
logback-core-1.2.9.jar
logback-classic-1.2.9.jar
Description
ch.qos.logback.core.rolling.helper.TimeBasedArchiveRemover class 's clean method
public void clean(Date now) {
long nowInMillis = now.getTime();
// for a live appender periodsElapsed is expected to be 1
int periodsElapsed = computeElapsedPeriodsSinceLastClean(nowInMillis);
lastHeartBeat = nowInMillis;
if (periodsElapsed > 1)
for (int i = 0; i < periodsElapsed; i++)
{ int offset = getPeriodOffsetForDeletionTarget() - i; Date dateOfPeriodToClean = rc.getEndOfNextNthPeriod(now, offset); cleanPeriod(dateOfPeriodToClean); }}
This method is invoked when deleting oldest log files.
logback's log_max_history option is depended on it.
computeElapsedPeriodsSinceLastClean(nowInMillis) method returns periodsElapsed value.
other method return 32. maybe ... 1 month.
int computeElapsedPeriodsSinceLastClean(long nowInMillis) {
long periodsElapsed = 0;
if (lastHeartBeat == UNINITIALIZED)
else
{ periodsElapsed = rc.periodBarriersCrossed(lastHeartBeat, nowInMillis); // periodsElapsed of zero is possible for size and time based policies } return (int) periodsElapsed;
}
is this right that i understand?
I found this during I tested logback's log_max_history option.
-> log_max_history=90 , today is 2021-12-22
2021-08-22 ~ 2021-09-22 log files are deleted.
-> log_max_history=30, today is 2021-12-22
2021-10-21 ~ 2021-11-21 log files are deleted.
-> log_max_history=7, today is 2021-12-22
2021-11-13 ~ 2021-12-14 log files are deleted.
-> log_max_history=1, today is 2021-12-22
2021-11-19 ~ 2021-12-20 log files are deleted.
I think there is the range... limit.
Is there any one tested this option?