You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "EbenZhang (JIRA)" <ji...@apache.org> on 2017/07/27 13:12:00 UTC

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

EbenZhang created LOG4NET-571:
---------------------------------

             Summary: 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


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
(v6.4.14#64029)