Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1603

logback log_max_history option's delete log calendar interval is 32

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.2.9
    • logback-core
    • 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)

      { 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? 

       

      Attachments

        Activity

          People

            logback-dev Logback dev list
            junmoKang junmoKang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: