You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Tomas Juocepis (JIRA)" <ji...@apache.org> on 2016/08/26 17:12:21 UTC

[jira] [Commented] (LOG4NET-454) Intermittent severe slowdown with RollingFileAppender+MinimalLock

    [ https://issues.apache.org/jira/browse/LOG4NET-454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15439407#comment-15439407 ] 

Tomas Juocepis commented on LOG4NET-454:
----------------------------------------

I work on a project which uses Log4Net. We've been encountering this exact issue over the last few years. We've worked around it by limiting log file size to 100kb, as the slowness seems to be proportional to the log file size. Recently we upgraded from v1.2.11 to 2.0.5. I removed the file size limit in the hopes that the slowness issue has been resolved in the newer version. It was working fine for a few weeks, even with large log files, however, today, the severe slowness has returned. We've reverted to the 100 kb file size limit workaround again. 

Our configuration when the issue occurs:
{code}
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="C:\somedir\%property{Environment}\%property{Environment} - %property{Version} - %property{UserId}" />
      <appendToFile value="true" />
      <staticLogFileName value="false" />
      <rollingStyle value="Date" />
      <datePattern value=" - [yyyy-MM-dd]'.log'" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] - %message%newline" />
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="DEBUG" />
        <levelMax value="ERROR" />
      </filter>
    </appender>
{code}

Our workaround configuration:
{code}
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="C:\somedir\%property{Environment}\%property{Environment} - %property{Version} - %property{UserId}" />
      <appendToFile value="true" />
      <staticLogFileName value="false" />
      <rollingStyle value="Date" />
      <datePattern value=" - [yyyy-MM-dd]'.log'" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] - %message%newline" />
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="DEBUG" />
        <levelMax value="ERROR" />
      </filter>
    </appender>
{code}

I hope this helps

> Intermittent severe slowdown with RollingFileAppender+MinimalLock
> -----------------------------------------------------------------
>
>                 Key: LOG4NET-454
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-454
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.13
>         Environment: ASP.NET MVC 5.2.2 Application, Windows 7 Professional
>            Reporter: Chuck Felish
>
> Using RollingFileAppender with MinimalLock we found an extreme slowdown in the processing of our application requests (from 300ms to up to 15s in some cases) which was resolved when we deleted our log files. We also found that changing the lock to Exclusive resolved the issue.
> Interestingly file content seemed to be related, but not file size. When I took the contents of a colleague's log file and pasted them into my own log file the slowness issue appeared again. I then tried deleting about half the contents and then causing the file to grow to larger than the original size but the issue did not return. Pasting the original contents back into the file caused the performance issue to return.
> While Exclusive lock has resolved our issue for now, it's quite unexpected that file contents would affect performance at all, and that the issue is does not consistently reproduce even though configuration is unchanged.
> I'm happy to demonstrate and/or share our problematic log files with you to facilitate the resolution of this issue.
> Our configuration is as follows:
>     <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
>         <file type="log4net.Util.PatternString" value="Logs\%property{ExecutableName}_%env{COMPUTERNAME}.log" />
>         <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>         <appendToFile value="true" />
>         <rollingStyle value="Size" />
>         <maximumFileSize value="5MB" />
>         <maxSizeRollBackups value="50" />
>         <preserveLogFileNameExtension value="true" />
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="%d{yyyy-MM-dd HH:mm:ss.fff} [%-5level][%5thread] %logger - %m%n" />
>         </layout>
>     </appender>
>     <root>
>         <!-- NOTE:  This is overriden programatically by Log4NetConfig.cs -->
>         <level value="ALL" />
> <!--        <appender-ref ref="ColorConsole" />-->
>         <appender-ref ref="RollingFile" />
>     </root>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)