Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Scott S 1 post 21 karma points
    Nov 18, 2014 @ 22:41
    Scott S
    0

    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>

    The following is logged to the log file:
    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?
    Thanks,
    Scott

     

  • Dallas 132 posts 404 karma points
    Jul 01, 2015 @ 10:11
    Dallas
    0

    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

  • Dallas 132 posts 404 karma points
    Aug 06, 2015 @ 21:16
    Dallas
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft