When does NLog capture the ThreadID?

948 views
Skip to first unread message

Chris Tracy

unread,
Jan 29, 2013, 10:07:41 AM1/29/13
to nlog-...@googlegroups.com

If I have async logging turned on in nlog.config, where is the ThreadID captured?

Context: I'm starting a greenfield project using .NET, Rx, and TPL Dataflow (a.k.a. TDP). It will make heavy use of async operations and background work queues.

Goal: In my logging I'd like to capture the ManagedThreadId where the work is being performed, and when work is being done in parallel (easy to get wrong in Rx, where default scheduler isn't ThreadPool). If I have async logging turned on in nlog.config, where is the ThreadID captured?

Concern: I don't see ThreadID in the core LogEntry class for NLog. For example it isn't sent to the browser in cbley/NLog.SignalR. If I have async logging turned on in nlog.config, where is the ThreadIDcaptured? If it isn't captured until the log entry is rendered (in an NLog background thread), then theThreadId is useless to me and I need to find a more appropriate logging library.

P.S. Cross-Posted to StackOverflow.com  http://stackoverflow.com/questions/14585906/when-does-nlog-capture-the-threadid

Jarek Kowalski

unread,
Jan 29, 2013, 11:52:41 AM1/29/13
to nlog-...@googlegroups.com
ThreadID is being captured at the time of logging, but only when you actually use ${threadid} layout renderer.

Jarek


--
You received this message because you are subscribed to the Google Groups "NLog-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nlog-users+...@googlegroups.com.
To post to this group, send email to nlog-...@googlegroups.com.
Visit this group at http://groups.google.com/group/nlog-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Tracy

unread,
Jan 29, 2013, 5:16:11 PM1/29/13
to nlog-...@googlegroups.com
I found [ThreadAgnostic] in NLog sources, and my understanding of NLog has just +1'ed.  This will be my first project making significant use of LogReceiverService, so the where & when of data capture is coming to the fore. 

Thanks.  Very helpful.

P.S.  I might ask another question regarding LogReceiverService and {threadid}, but enjoying the NLog sources enough that I'm going to keep reading for a while first.
Reply all
Reply to author
Forward
0 new messages