[
https://issues.apache.org/jira/browse/LOG4NET-672?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17504945#comment-17504945
]
Davyd McColl edited comment on LOG4NET-672 at 3/11/22, 2:28 PM:
----------------------------------------------------------------
[~AkhilB402] apologies for the long wait - I had to resolve another issue
first, with xml output on !netfx, and then, life.
There definitely is an issue here with casing, but I don't think that doing a
blanket case-insensitive match is the correct way forward. Windows filesystems
(and, confirming with my old mac here, OSX ones) may not care about casing, but
Linux filesystems generally do. It's odd, if you think about it, when modern
systems _don't_ care about casing - they sure _show_ the different casing when
displaying files.
So I think what I'd want to do here is twofold:
1. Windows is unlikely to ever have a case-sensitive filesystem api, to support
legacy operations (probably the same for OX). In this case, the test should
always be case-insensitive
2. Linux machines are unlikely to have case-insensitive filesystems, and,
anyway, it feels like a bug if you've asked for your file to be created with
the pattern `yyyy-MM-dd-'Xyz'` and it comes out as `2022-03-11-xyz`, so I'd
like to fix that output.
In the meantime, you can work around this by making the parts of your filename
pattern which aren't date specifiers, all lower-case, ie, in this case,
`yyyy-MM-dd-'xyz'`.
was (Author: davydm):
[~AkhilB402] apologies for the long wait - I had to resolve another issue
first, with xml output on !netfx, and then, life.
There definitely is an issue here with casing, but I don't think that doing a
blanket case-insensitive match is the correct way forward. Windows filesystems
(and, confirming with my old mac here, OSX ones) may not care about casing, but
Linux filesystems generally do. It's odd, if you think about it, when modern
systems _don't_ care about casing - they sure _show_ the different casing when
displaying files.
So I think what I'd want to do here is twofold:
1. Windows is unlikely to ever have a case-sensitive filesystem api, to support
legacy operations (probably the same for OX). In this case, the test should
always be case-insensitive
2. Linux machines are unlikely to have case-insensitive filesystems, and,
anyway, it feels like a bug if you've asked for your file to be created with
the pattern `yyyy-MM-dd-'Xyz'` and it comes out as `2022-03-11-xyz`, so I'd
like to fix that output.
In the meantime, you can work around this by making your filename pattern all
lower-case.
> Previous rolled files not taken into consideration after restart the Logging
> Manager with a specific date-pattern
> ------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4NET-672
> URL: https://issues.apache.org/jira/browse/LOG4NET-672
> Project: Log4net
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.0.10
> Reporter: Akhil Bandari
> Priority: Critical
>
> {code:xml}
> <log4net>
> <appender name="LogFileAppenderXML"
> type="log4net.Appender.RollingFileAppender"> <file
> value="Logs\.xml" />
> <datePattern value="yyyy-MM-dd-'Xyz'" />
> <appendToFile value="true" />
> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
> <rollingStyle value="Composite" />
> <maxSizeRollBackups value="40" />
> <maximumFileSize value="1MB" />
> <preserveLogFileNameExtension value="true" />
> <staticLogFileName value="true" />
> <layout type="log4net.Layout.XmlLayout"/>
> </appender>
> <root>
> <level value="ALL"/>
> <appender-ref ref="LogFileAppenderXML"></appender-ref>
> </root>
> </log4net>
> {code}
>
> With the above configuration, the rolling was working fine for a single run
> of the application, but after a restart of the logging manager (or the
> application), the previous rolled files are overwritten instead of new rolled
> files being created with the last highest rolled file index.
> +*Steps to reproduce:*+
> # Create an application [console or wpf] with the above log4net config
> # Start logging
> ## Until At least 10 rolled files are created
> # Close and ReStart the application
> # Start logging again
> ## Observe the rolled files
> ## Start logging and when the logging information reaches to
> maximumFileSize, {color:#172b4d}the previous rolled file content will be
> overwritten with new content, _*instead of increasing the rolled file
> count.*_{color}
> {color:#172b4d}Looked into the source code of *RollingFileAppender* found
> that {color}
> * {color:#172b4d}At the initial phase all the rolled file names, are
> converted into the *LowerInvariant and* passing to the
> *InitializeFromOneFile* method{color}
>
> {code:c#}
> private void InitializeRollBackups(string baseFile, ArrayList arrayFiles)
> {
> if (null != arrayFiles)
> {
> string baseFileLower = baseFile.ToLowerInvariant();
> foreach(string curFileName in arrayFiles)
> {
>
> InitializeFromOneFile(baseFileLower,curFileName.ToLowerInvariant());
> }
> }
> }
> {code}
> - Inside *InitializeFromOneFile*
> - The date variable is not converting to lower or while comparing the
> *curFileName with a prefix not using ignoreCase*
> - that is leading not to get last rolled file index
> {code:c#}
> if (!curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix))
> {
> LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"]
> because it is from a different date period");
> return;
> }
> {code}
> Is there any possibility to use ignoreCase while comparing curFileName with
> the prefix
> {code:c#}
> if (!curFileName.StartsWith(prefix,true,CultureInfo.InvariantCulture) ||
> !curFileName.EndsWith(suffix))
> {code}
>
> Or is there any reason not to _*use ignoreCase while comparing curFileName*_
> with the _*prefix?*_
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)