Return-Path: X-Original-To: apmail-logging-log4net-user-archive@www.apache.org Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BB39C7291 for ; Tue, 29 Nov 2011 16:11:39 +0000 (UTC) Received: (qmail 91355 invoked by uid 500); 29 Nov 2011 16:11:39 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 91301 invoked by uid 500); 29 Nov 2011 16:11:38 -0000 Mailing-List: contact log4net-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET User" List-Id: Delivered-To: mailing list log4net-user@logging.apache.org Received: (qmail 91293 invoked by uid 99); 29 Nov 2011 16:11:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 16:11:38 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of andrewarnott@gmail.com designates 209.85.216.47 as permitted sender) Received: from [209.85.216.47] (HELO mail-qw0-f47.google.com) (209.85.216.47) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 16:11:30 +0000 Received: by qaea17 with SMTP id a17so2353393qae.13 for ; Tue, 29 Nov 2011 08:11:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=3ZXkF9iYEBtH8BYJJ4llL4gTJy2JrMKMlrlvhP73L4s=; b=LZoQkRkcwLt93ANOhyWUypC2hcp16mjFSPnPiM2vY09xOueiWQR6ZermuPILNL08O5 I/SygXSm4HHsBlXzXCXmtGvMw91ax9Qm3e3zgWmurYm5TvDpYq97rgxMMl8EwrQ4B8cu fuY8Pg8QSi/0tawNIniL5HiZc7387Dc6l5cRU= Received: by 10.224.189.66 with SMTP id dd2mr12815944qab.48.1322583069425; Tue, 29 Nov 2011 08:11:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.74.134 with HTTP; Tue, 29 Nov 2011 08:10:48 -0800 (PST) In-Reply-To: <878vmztsta.fsf@v35516.1blu.de> References: <871ussb367.fsf@v35516.1blu.de> <878vmztsta.fsf@v35516.1blu.de> From: Andrew Arnott Date: Tue, 29 Nov 2011 08:10:48 -0800 Message-ID: Subject: Re: ThreadLogicalContext not actually following logical threads To: Log4NET User Content-Type: multipart/alternative; boundary=20cf3033465509ff8704b2e1de8e X-Virus-Checked: Checked by ClamAV on apache.org --20cf3033465509ff8704b2e1de8e Content-Type: text/plain; charset=ISO-8859-1 I'd be happy to help. But given the fact that I'm a Microsoft employee with some strict open source restrictions, I can only provide support for it. In short, if log4net stores its logical call-tracking context stack using CallContext.LogicalSetData and retrieves it using the similarly named method, everything should automatically work. If not, I can hopefully provide additional help. -- Andrew Arnott "I [may] not agree with what you have to say, but I'll defend to the death your right to say it." - S. G. Tallentyre On Mon, Nov 28, 2011 at 9:13 PM, Stefan Bodewig wrote: > On 2011-11-28, Andrew Arnott wrote: > > > The documentation is poor, I agree. I had to stumble around quite a bit > > before I figured out how to use it properly myself. I believe the > > difference may be that CallContext.*Logical*SetData requires the value to > > be serializable, so that it can be cloned and applied to other threads, > > perhaps even in separate appdomains. > > > This sounds like an area that log4net can improve then. > > For .NET 2+, yes. > > > I'm not sure why log4net claims to follow the logical thread when > > apparently it doesn't. > > It probably does in some circumstances but obviously not all of them. > > > The good news is that in the absence of built-in support from log4net, > I've > > engineered a solution of my own by controlling the > > HostExecutionContextManager in my AppDomain. Whenever the logical thread > > forks (i.e. threadpool use, c# 5 async keyword, etc.) my code "captures" > > the current context stack from log4net and applies that stack to the new > > thread, and "reverts" that change when the target thread has completed > its > > work for that call. > > > Pretty cool stuff, but it would be cooler if log4net had it built-in. > > Oh, feel free to help log4net improve here 8-) > > Cheers > > Stefan > --20cf3033465509ff8704b2e1de8e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'd be happy to help. =A0But given the fact that I'm a Microsoft em= ployee with some strict open source restrictions, I can only provide suppor= t for it. =A0

In short, if log4net stores its logical ca= ll-tracking context stack using=A0CallContext.LogicalSetDat= a and retrieves it using the similarly named method, everything should auto= matically work. =A0If not, I can hopefully provide additional help.<= /div>

--
Andrew Arnott
"I [may] not a= gree with what you have to say, but I'll defend to the death your right= to say it." - S. G. Tallentyre


On Mon, Nov 28, 2011 at 9:13 PM, Stefan = Bodewig <bodewig= @apache.org> wrote:
On 2011-11-28, Andrew Arnott wrote:

> The documentation is poor, I agree. =A0I had to stumble around quite a= bit
> before I figured out how to use it properly myself. =A0I believe the
> difference may be that CallContext.*Logical*SetData requires the= value to
> be serializable, so that it can be cloned and applie= d to other threads,
> perhaps even in separate appdomains.

> This sounds like an area that log4net can improve then.

For .NET 2+, yes.

> I'm not sure why log4net claims to follow the logical thread when<= br> > apparently it doesn't.

It probably does in some circumstances but obviously not all of them.=

> The good news is that in the absence of built-in support from log4net,= I've
> engineered a solution of my own by controlling the
> HostExecutionContextManager in my AppDomain. =A0Whenever the logical t= hread
> forks (i.e. threadpool use, c# 5 async keyword, etc.) my code "ca= ptures"
> the current context stack from log4net and applies that stack to the n= ew
> thread, and "reverts" that change when the target thread has= completed its
> work for that call.

> Pretty cool stuff, but it would be cooler if log4net had it built-in.<= br>
Oh, feel free to help log4net improve here 8-)

Cheers

=A0 =A0 =A0 =A0Stefan

--20cf3033465509ff8704b2e1de8e--