[logback-dev] [JIRA] Updates for LOGBACK-1603: logback log_max_history option's delete log calendar interval is 32
QOS.CH (JIRA)
noreply-jira at qos.ch
Thu Dec 23 09:19:00 CET 2021
logback / LOGBACK-1603 [Open]
logback log_max_history option's delete log calendar interval is 32
==============================
Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.
View or comment on issue using this link
https://jira.qos.ch/browse/LOGBACK-1603
==============================
Issue created
------------------------------
junmoKang created this issue on 23/Dec/21 9:06 AM
Summary: logback log_max_history option's delete log calendar interval is 32
Issue Type: Improvement
Affects Versions: 1.2.9
Assignee: Logback dev list
Components: logback-core
Created: 23/Dec/21 9:06 AM
Environment:
logback-core-1.2.9.jar
logback-classic-1.2.9.jar
Priority: Major
Reporter: junmoKang
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) {
addInfo("Multiple periods, i.e. " + periodsElapsed + " periods, seem to have elapsed. This is expected at application start.");
}
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) {
addInfo("first clean up after appender initialization");
periodsElapsed = rc.periodBarriersCrossed(nowInMillis, nowInMillis + INACTIVITY_TOLERANCE_IN_MILLIS);
periodsElapsed = Math.min(periodsElapsed, MAX_VALUE_FOR_INACTIVITY_PERIODS);
} 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?
==============================
This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)
More information about the logback-dev
mailing list