U4-6063 - Increase Log Queue Size

Created by Nicholas Westby 31 Dec 2014, 23:43:54 Updated by Shannon Deminick 28 Jun 2016, 09:44:39

Relates to: U4-2037

Noticed this error in my Umbraco log file:

2014-12-31 23:26:37,244 [47] ERROR Umbraco.Core.Logging.AsynchronousRollingFileAppender - Buffer overflow. 1353 logging events have been lost in the last 30 seconds. [QueueSizeLimit: 1000]

This issue appears to stem from [https://github.com/umbraco/Umbraco-CMS/blob/5b9a98ad6ae9e63322c26f7b162204e34f7fcb54/src/Umbraco.Core/Logging/AsynchronousRollingFileAppender.cs AsynchronousRollingFileAppender]

It seems there is a hardcoded "_queueSizeLimit" of 1000. Since I just encountered this error, maybe this limit should be increased or be configurable? I see no reason to keep it that low.

If you are curious, I encountered this error while running an import process (I log a bunch of info so I can be sure the import went smoothly).

Comments

Shannon Deminick 01 Jul 2015, 11:57:41

In 7.3, this is a public get/set option


Nicholas Westby 23 May 2016, 19:04:26

@Shandem I was just going to try this out, but it's unclear to me exactly how I can set this property. I'm not sure how to get the current instance of AsynchronousRollingFileAppender. I was thinking something like this (untested), though it seems overly complicated, so I'm guessing there is a better way:

var appenders = LogManager.GetRepository().GetAppenders();
foreach (var appender in appenders)
{
    var casted = appender as AsynchronousRollingFileAppender;
    if (casted != null)
    {
        casted.QueueSizeLimit = 100000;
    }
}


Nicholas Westby 23 May 2016, 19:13:54

Hmm, that didn't seem to work (there was no AsynchronousRollingFileAppender in the collection).


Shannon Deminick 28 Jun 2016, 09:44:39

The default logging config used in Umbraco is:

<?xml version="1.0"?>
<log4net>
  
  <root>
    <priority value="Info"/>
    <appender-ref ref="AsynchronousLog4NetAppender" />
  </root>

  <appender name="rollingFile" type="log4net.Appender.RollingFileAppender">
	  <file type="log4net.Util.PatternString" value="App_Data\Logs\UmbracoTraceLog.%property{log4net:HostName}.txt" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <maximumFileSize value="5MB" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value=" %date [P%property{processId}/D%property{appDomainId}/T%thread] %-5level %logger - %message%newline" />
    </layout>
    <encoding value="utf-8" />
  </appender>

  <appender name="AsynchronousLog4NetAppender" type="Umbraco.Core.Logging.ParallelForwardingAppender,Umbraco.Core">
    <appender-ref ref="rollingFile" />
  </appender>

  <!--Here you can change the way logging works for certain namespaces  -->

  <logger name="NHibernate">
    <level value="WARN" />
  </logger>
  
  
</log4net>

If you have upgraded from an older version of Umbraco be sure to update the logging appenders as these ones works much better. Perhaps you already have this new logging configuration and therefore you are looking at the wrong appender type.


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.1.8

Due in version: 7.3.0

Sprint:

Story Points:

Cycle: