logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chinh Do <...@vienxu.com>
Subject Re: asynchronous logging
Date Wed, 31 Jul 2013 02:07:06 GMT
Yes I was referring to log4net.Core.LoggingEvent.Properties.

In my case, I know exactly what I need so I just had a few lines of code
like this:

// Implementation of IAppender.DoAppend
public void DoAppend(LoggingEvent loggingEvent) {
    loggingEvent.Properties["ThreadId"] =
Thread.CurrentThread.ManagedThreadId.ToString();
    loggingEvent.Properties["MyUserId"] = ...
    loggingEvent.Properties["MySessionId"] = ...
    ...
    AddToQueue(loggingEvent);
}



On Tue, Jul 30, 2013 at 5:42 PM, Farrington, Linda
<lfarrington@aclara.com>wrote:

>  Chinh Do,****
>
> Thanks for your suggestion.  This sounds like it might work.  I did not
> write this component, we are using one that someone else wrote and posted
> on github.  Are you talking about the Properties() that is on the
> LoggingEvent object?  If so, there is a point in the code where I see the
> correct data in ThreadingContext.  I could get it out of there and put it
> into Properties.  However, I have not been able to find a way to iterate
> through the ThreadingContext because it does not have a GetEnumerator on
> it. How are you able to get data out of the threadContext?****
>
> ** **
>
> *From:* chinhdo@gmail.com [mailto:chinhdo@gmail.com] *On Behalf Of *Chinh
> Do
> *Sent:* Tuesday, July 30, 2013 4:28 PM
> *To:* Log4NET Dev
> *Subject:* Re: asynchronous logging****
>
> ** **
>
> What I did my my AsyncAppender was to write thread specific data into
> loggingEvent.Properties in the main thread, just before I add the
> loggingEvent to a queue. Then you can use "%P{<PropertyName>}" in your
> log4net config section to get them later in the other thread.****
>
> ** **
>
> My AsyncAppender was based on log4net AsyncAppender example (see
> http://logging.apache.org/log4net/release/example-apps.html). The log
> events sent to AsyncAppender are forwarded asynchronously to a list of
> attached appenders.****
>
> ** **
>
> On Tue, Jul 30, 2013 at 2:31 PM, George Chung <george@glympse.com> wrote:*
> ***
>
> If you authored your own AsynchronousAdoNetAppender that uses the new .NET
> async/await constructs, you could use the TPL library to wrap the ado.netasync operations
as a Task.
> ****
>
> ** **
>
> Then if you *avoid *calling ConfigureAwait(false), I'm pretty sure the
> completion routine will complete on the original ASP.NET request thread,
> in which case you'll have access to the original HttpContext that started
> the request.****
>
> ** **
>
> ** **
>
> On Tue, Jul 30, 2013 at 8:31 AM, Farrington, Linda <lfarrington@aclara.com>
> wrote:****
>
> We are trying to log asynchronously using an asynchronousadonetappender
> inherited from adonetappender.   Logging standard properties seems to work
> fine, but custom properties do not.  I understand that this is because the
> asynchronous appender is logging the messages on another thread and we're
> storing the custom properties in the logicalthreadcontext (tried
> threadcontext = as well to no avail).  My question is this:  If I cannot
> use the threadcontext when running asynchronously, how should I pass custom
> properties into log4net.  Has anyone else done this?  Can anyone provide
> any suggestions?****
>
>  ****
>
> Thanks in advance,****
>
>  ****
>
> Linda****
>
>  ****
>
>  ****
>
>  ****
>
> ** **
>
>
>
> ****
>
> ** **
>
> --
> http://www.chinhdo.com ****
>



-- 
http://www.chinhdo.com

Mime
View raw message