[
https://issues.apache.org/jira/browse/LOG4NET-465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17803333#comment-17803333
]
Wolfgang Knauf commented on LOG4NET-465:
----------------------------------------
Is this still relevant in 2.0.15 and .NET6? I found this issue when researching
a similar issue. But for me, it turned out to be a problem in my log4net config
file. After changing the config, the rolling log files are kept after an app
restart. So I hope it was fixed in the meantime.
For the records: in my problematic config i had defined the file extension as
part of the date pattern (found this hint somewhere in the web years ago) - but
it caused problems with size rolling log files:
{quote} <appender name="InformationAppender"
type="log4net.Appender.RollingFileAppender">
<file value="logfile_" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maximumFileSize value="50MB"/>
<maxSizeRollBackups value="10"/>
<preserveLogFileNameExtension value="true"/>
<staticLogFileName value="false" />
<datePattern value="{color:#de350b}yyyy-MM'.log'{color}" />
</appender>
{quote}
And this is the working config (thanks to the creator of this bug anyway, as it
pointed me in the right direction):
{quote} <appender name="InformationAppender"
type="log4net.Appender.RollingFileAppender">
<file value="logfile_.log" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maximumFileSize value="50MB"/>
<maxSizeRollBackups value="10"/>
<preserveLogFileNameExtension value="true"/>
<staticLogFileName value="false" />
<datePattern value="yyyy-MM" />
</appender>
{quote}
My only difference to the config file from the initial bugreport: I use the
default "CountDirection".
> Rolling log files get overwritten when IIS is restarted
> -------------------------------------------------------
>
> Key: LOG4NET-465
> URL: https://issues.apache.org/jira/browse/LOG4NET-465
> Project: Log4net
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 1.2.13
> Environment: asp.net 4.0
> Reporter: Michel Emond
> Priority: Major
> Attachments: RollingFileAppender.diff, config.xml
>
>
> This is the issue described in LOG4NET-378
> h2. Reproduction steps
> # Setup a web application using the settings from the attached config.xml file
> # Notice the rolling style set to Composite
> # Start and use the application
> # The log files pile up in the folder
> # Restart IIS
> # 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
> h2. 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:
> {code}
> DetermineCurSizeRollBackups()
> |
> +--GetExistingFiles()
> | +--GetWildcardPatternForFile()
> |
> +--InitializeRollBackups()
> +--InitializeFromOneFile()
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)