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

option to create new file on start of SizeAndTimeBasedFNATP

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • logback-core
    • None

    Description

      It would be nice to have the option of having the SizeAndTimeBasedFNATP always create a new file on a restart (only applicable when <File> is not specified – only the <FileNamePattern>). Currently, if a process locks the latest file while the appender is stopped, then the FileAppender.openFile will fail if the file is still locked when the appender starts again.

      I'm currently accomplishing this by overriding SizeAndTimeBasedFNATP.start and using reflection to increment the currentPeriodsCounter.

      If a boolean option (e.g. "newFileOnStart") was added to SizeAndTimeBasedFNATP and computeCurrentPeriodsHighestCounterValue was modified to return whether or not a matching file was found, then the start method could be modified as shown below:

      if (tbrp.getParentsRawFileProperty() == null) {
      String regex = tbrp.fileNamePattern.toRegex(dateInCurrentPeriod);
      String stemRegex = FileFilterUtil.afterLastSlash(regex);
      // beginning of changes
      boolean fileExists = computeCurrentPeriodsHighestCounterValue(stemRegex);
      if (fileExists && newFileOnStart)

      { currentPeriodsCounter++; }

      // end of changes
      }

      Attachments

        Activity

          People

            logback-dev Logback dev list
            rcogswell Ryan Cogswell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: