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

TimeBasedRollingPolicy#rollover leaves tmp file when archive file with same date already exists

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.0.6
    • None
    • None
    • Linux

    Description

      Use rolling policy with archiving to gz. When system time set to past, rollover produces tmp file.

      How to reproduce:

      1. logging event creates log file <filename>.log
      2. system time passes midnight = new day
      3. logging event triggers rollover and creation of archive <filename>.log.<YYYYMMDD>
      4. system time changes so now it points previous day.
      5. logging event triggers rollover but fails to archive current <filename>.log since the file <filename>.log.<YYYYMMDD> already exists.

      You use System.nanoTime() to make name of temporary file. Do you see any performance/security issues to use File.createTempFile? My concern is that you still should check if some file already exists.

      It would be nice to have ability to create additional level of rolling <filename>.log.<YYYYMMDD>.<INDEX>. So i guess if code checks if target file exists it tries to match additional suffix to make file unique.

      So far I see the code doesn't check if the archive file already exists.

      TimeBasedRollingPolicy.java

      Future renamedRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName)
      throws RolloverFailure

      { String parentsRawFile = getParentsRawFileProperty(); String tmpTarget = parentsRawFile + System.nanoTime() + ".tmp"; renameUtil.rename(parentsRawFile, tmpTarget); return asyncCompress(tmpTarget, nameOfCompressedFile, innerEntryName); }

      Attachments

        Activity

          People

            logback-dev Logback dev list
            lol1 lol
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: