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:06 UTC

[jira] [Updated] (LOG4NET-571) Rolling by size, Preserve Extension, and Folder don't work together

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

Ralph Goers updated LOG4NET-571:
--------------------------------

LOG4NET is now dormant.  

> Rolling by size, Preserve Extension, and Folder don't work together
> -------------------------------------------------------------------
>
>                 Key: LOG4NET-571
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-571
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0.8
>            Reporter: EbenZhang
>            Priority: Major
>
> Those three don't work well together, the oldest file won't be deleted, e.g.
> {code:xml}
> <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>
> {code}
> Because in [RollingFileAppender line 1496|https://github.com/Nicologies/logging-log4net/blob/develop/src/Appender/RollingFileAppender.cs#L1496], the folder will be stripped, as a result the code is unable to find the file to delete.
> {code:java}
> string extension = Path.GetExtension(archiveFileBaseName);
> string baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
> int lastDotIndex = baseName.LastIndexOf(".");
> if (lastDotIndex >= 0)
> {
>     archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)