log4net %property not displaying for AsynchronousRollingFileAppender
When I use the AsynchronousRollingFileAppender appender, custom properties and aspnet- values are not being written to the log. Here is an example of the pattern layout that I'm using.
2014-11-18 16:29:09,929 [27] DEBUG [(null)] [NOT AVAILABLE] TestUmbracoSite.ProductController - Some log message here
If I change to use the built in log4net appender RollingFileAppender, the values are written to the log, so I know the code is correct to set the parameter.
Is this a limitation to the AsynchronousRollingFileAppender appender?
A co-worker of is using Umbraco v6.x and the AsynchronousRollingFileAppender appender seems to work fine in version 6.x. Did something change?
What is the reason for using AsynchronousRollingFileAppender instead of RollingFileAppender?
From looking at the source my understanding is that the AsynchronousRollingFileAppender is for performance. The logs are written on a background thread rather than the main thread.
The umbraco appender is based off of code from this example:
I also found that the log4net custom properties are not logged correctly and display as (null) in the log file. I think this is because the properties are set on the main thread and don't exist on the background thread.
log4net %property not displaying for AsynchronousRollingFileAppender
When I use the AsynchronousRollingFileAppender appender, custom properties and aspnet- values are not being written to the log. Here is an example of the pattern layout that I'm using.
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level [%P{requestId}] [%aspnet-context{requestId}] %logger - %message%newline" />
</layout>
From looking at the source my understanding is that the AsynchronousRollingFileAppender is for performance. The logs are written on a background thread rather than the main thread.
The umbraco appender is based off of code from this example:
http://cjbhaines.wordpress.com/2012/02/13/asynchronous-log4net-appenders/
I also found that the log4net custom properties are not logged correctly and display as (null) in the log file. I think this is because the properties are set on the main thread and don't exist on the background thread.
Dallas
This blog post explains some of the issues with properties disappearing in asp.net.
http://piers7.blogspot.fr/2005/12/log4net-context-problems-with-aspnet.html
is working on a reply...