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

SizeAndTimeBasedFNATP counter compute failure

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • logback-core
    • Occurs on Windows, not confirmed on other platforms.

    Description

      When TimeBasedRollingPolicy fileNamePattern is set to just a file, for example toto-%d{yyyy-MM-dd}-%i.log, then the following code from SizeAndTimeBasedFNATP class fails to detect parent directory and assumes counter = 0 even if there are already ZIP files in the directory. This leads to file name collision during rolling.

       

      void computeCurrentPeriodsHighestCounterValue(final String stemRegex) {
          File file = new File(getCurrentPeriodsFileNameWithoutCompressionSuffix());
          File parentDir = file.getParentFile();
      
          File[] matchingFileArray = FileFilterUtil.filesInFolderMatchingStemRegex(parentDir, stemRegex);
      
          if (matchingFileArray == null || matchingFileArray.length == 0) {
              currentPeriodsCounter = 0;
              return;
          }
        ...
      }

      file.getParentFile() returns null in this case. The workaround is to prefix file name pattern with ./ (./*toto-%d{yyyy-MM-dd}-%i.log). I believe the current working directory should be used as parent directory when parentDir resolves to null.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            rgala Rafał Gała
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: