Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-465

Rolling log files get overwritten when IIS is restarted

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.13
    • None
    • Appenders
    • None
    • asp.net 4.0

    Description

      This is the issue described in LOG4NET-378

      Reproduction steps

      1. Setup a web application using the settings from the attached config.xml file
      2. Notice the rolling style set to Composite
      3. Start and use the application
      4. The log files pile up in the folder
      5. Restart IIS
      6. Keep using the application

      Expected result

      • The rolling continues on or after the last file

      Actual result

      • The rolling restarts at index 1 and overwrites the existing files

      Solution

      See the attached files:

      • config.xml
      • patch with a fix proposal

      The original bug fix addresses the issue in the InitializeFromOneFile() method.
      However, the GetWildcardPatternForFile() method also needs the baseFileName to be adjusted with the datePattern so the proper files are searched.
      I placed a file path fix in the DetermineCurSizeRollBackups() method, so it's then passed down to the two other methods and everyone gets happy.

      Here's a calling stack sample:

      DetermineCurSizeRollBackups()
      |
      +--GetExistingFiles()
      |  +--GetWildcardPatternForFile()
      |
      +--InitializeRollBackups()
         +--InitializeFromOneFile()
      

      Attachments

        1. config.xml
          2 kB
          Michel Emond
        2. RollingFileAppender.diff
          1 kB
          Michel Emond

        Issue Links

          Activity

            People

              Unassigned Unassigned
              memond Michel Emond
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: