RollingFileAppender does not roll more than one time when 
PreserveLogFileNameExtension is true
----------------------------------------------------------------------------------------------

                 Key: LOG4NET-203
                 URL: https://issues.apache.org/jira/browse/LOG4NET-203
             Project: Log4net
          Issue Type: Bug
          Components: Appenders
         Environment: I'm using the trunk
            Reporter: Scott Alexander


Method InitializeFromOneFile in RollingFileAppender.cs does not take into 
account the file extension. To repro setup an appender like so

 var appender = new DevicePointValueCsvAppender
            {
                MaxFileSize = 
ConfigurationManager.AppSettings[MaxFileSizeName].IfNotNull(max => 
OptionConverter.ToFileSize(max, DefaultMaxFileSize), DefaultMaxFileSize),
                MaxSizeRollBackups = 6,// 
ConfigurationManager.AppSettings[MaxSizeRollBackupsName].IfNotNull(max => 
Int32.Parse(max), DefaultMaxSizeRollBackups),                
                Layout = new PatternLayout { ConversionPattern = 
PatternLayout.DefaultConversionPattern },
                File = String.Format(CultureInfo.InvariantCulture, 
FileNameFormat, modbusMasterName),                
                RollingStyle = RollingFileAppender.RollingMode.Composite,
                PreserveLogFileNameExtension = true,
                StaticLogFileName = false,
                AppendToFile = false
            };

When the logger initializes the call to InitializeRollBackups is made whic 
incorrectly calculates the pre-existing number of backups, due to the fact that 
the file extension is being included in the following line

if (! curFileName.StartsWith(CombinePath(baseFile, 
m_dateTime.Now.ToString(m_datePattern, 
System.Globalization.DateTimeFormatInfo.InvariantInfo))))

The previous line should be replaced with something like the following

 string baseComparison = CombinePath(baseFile, 
m_dateTime.Now.ToString(m_datePattern, 
System.Globalization.DateTimeFormatInfo.InvariantInfo));
                if (m_preserveLogFileNameExtension)
                    baseComparison = 
Path.GetFileNameWithoutExtension(baseComparison);

                                if (! curFileName.StartsWith(baseComparison))


Thanks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to