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

Rolling by size, Preserve Extension, and Folder don't work together

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.8
    • Fix Version/s: None
    • Component/s: Appenders
    • Labels:
      None

      Description

      Those three don't work well together, the oldest file won't be deleted, e.g.

      <appender name="MyAppender" type="log4net.Appender.RollingFileAppender">
            <file type="log4net.Util.PatternString" value="SomeFolder\myLog.txt" />
            <appendToFile value="true" />
            <rollingStyle value="size" />
            <maximumFileSize value="2KB"/>
            <maxSizeRollBackups value="10"/>
            <countDirection value="1"/>
            <preserveLogFileNameExtension value="true"/>
            <staticLogFileName value="false" />
      </appender>
      

      Because in RollingFileAppender line 1496, the folder will be stripped, as a result the code is unable to find the file to delete.

      string extension = Path.GetExtension(archiveFileBaseName);
      string baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
      int lastDotIndex = baseName.LastIndexOf(".");
      if (lastDotIndex >= 0)
      {
          archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                EbenZhang EbenZhang
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: