You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2020/04/04 22:30:04 UTC

[jira] [Updated] (LOG4NET-203) RollingFileAppender does not roll more than one time when PreserveLogFileNameExtension is true

     [ https://issues.apache.org/jira/browse/LOG4NET-203?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers updated LOG4NET-203:
--------------------------------

LOG4NET is now dormant.  

> 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
>            Priority: Major
>             Fix For: 1.2/2.0 Maintenance Release
>
>
> 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 was sent by Atlassian Jira
(v8.3.4#803005)