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 ED09E11C2C for ; Fri, 15 Aug 2014 13:20:14 +0000 (UTC) Received: (qmail 25173 invoked by uid 500); 15 Aug 2014 13:20:14 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 25134 invoked by uid 500); 15 Aug 2014 13:20:14 -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 25124 invoked by uid 99); 15 Aug 2014 13:20:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Aug 2014 13:20:14 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ananth.tatachar@gmail.com designates 209.85.213.172 as permitted sender) Received: from [209.85.213.172] (HELO mail-ig0-f172.google.com) (209.85.213.172) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Aug 2014 13:20:09 +0000 Received: by mail-ig0-f172.google.com with SMTP id h15so1859954igd.5 for ; Fri, 15 Aug 2014 06:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=mXdkREDcLIO0P10HgldOWXf7NXegCGv8V/gnaTOoOrM=; b=nFxUuji4Kjh0CYQDA/ydFlMdmbsdaU1Du7IB5hvxt1oPd8Ah3ls2q231eGyLezQI+5 tY7SUwjVySRkGLJY62fj/o2eXfvh0NqQ6Cqcmo/r68rr8yRSqaJXXKY/SeQ3t0Quu63g IWSuGqapLV3gX7rym88HhmEUAKE5PeIdZwOdkibGjD77o32JhFRbSjVqDNM4JPpHBUNh pwWJCjUvDluPraoCshfpY1cNmnxn/MaB/keeXhI6fs8aZ33Qtd5SY/+Bgbi1DsIsukUc s/teelM4RzPdv/5nM82nr8LzEonvC4kbIHVsJWGX5lipUMSBaK7y2Zm0o6U+PbHx02hd D12w== MIME-Version: 1.0 X-Received: by 10.50.79.195 with SMTP id l3mr65558182igx.23.1408108789052; Fri, 15 Aug 2014 06:19:49 -0700 (PDT) Received: by 10.107.19.197 with HTTP; Fri, 15 Aug 2014 06:19:48 -0700 (PDT) In-Reply-To: References: Date: Fri, 15 Aug 2014 09:19:48 -0400 Message-ID: Subject: Re: Inconsistent results observed while using BufferingForwardAppender From: Ananth Tatachar To: Log4NET User Content-Type: multipart/alternative; boundary=089e01182d0a2d3bf20500aae077 X-Virus-Checked: Checked by ClamAV on apache.org --089e01182d0a2d3bf20500aae077 Content-Type: text/plain; charset=UTF-8 Thanks a lot Sir, I will implement this idea and I will let you know if it works for me. On Thu, Aug 14, 2014 at 1:45 PM, Michael Schall wrote: > Try adding the thread name to your conversion to ensure it is a different > thread > > > > It seems more likely that a thread is being reused. > > Mike > > > On Thu, Aug 14, 2014 at 10:51 AM, Ananth Tatachar < > ananth.tatachar@gmail.com> wrote: > >> I am working with log4net version : 1.2.12.0 . >> >> >> >> I am getting inconsistent results , while using RollingFileAppender with >> BufferingForwardAppender. >> >> My application is a multithreaded application. I spawned 5 threads Each >> will call the constructor of MyClass and SomeFunction once. >> >> My application's sertup is as follows: >> >> >> >> Web.config: >> >> ------------------------------- >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Logging Class: >> >> -------------------------- >> >> >> >> Class MyClass >> >> { >> >> public MyClass() >> >> { >> >> Log4net.ThreadContext.Properties["guid"] = Guid.NewGuid(); >> >> } >> >> >> >> public void SomeFunction() >> >> { >> >> Ilog log = LogManager.GetLogger(typeof(MyClass)); >> >> Log.Info("my message"); >> >> } >> >> >> >> } >> >> >> >> >> >> Tfile.log(Result) >> >> ---------------------- >> >> Observed Results: >> >> >> >> INFO 2014-08-14T10:47:36.659-04:00 ANANTHTATACHAR MyAudsDigest >> [LQR-Y8c71EmtWl7ZqItYoQ] my message >> >> INFO 2014-08-14T10:47:36.659-04:00 ANANTHTATACHAR MyAudsDigest >> [9hDzS-_Su0SrEoXZF_aGMw] my message >> >> INFO 2014-08-14T10:47:36.729-04:00 ANANTHTATACHAR MyAudsDigest >> [GsxT7aTfNEq1uIsqPYeZ5w] my message >> >> INFO 2014-08-14T10:47:36.789-04:00 ANANTHTATACHAR MyAudsDigest >> [9hDzS-_Su0SrEoXZF_aGMw] my message >> >> INFO 2014-08-14T10:47:36.955-04:00 ANANTHTATACHAR MyAudsDigest >> [9hDzS-_Su0SrEoXZF_aGMw] my message >> >> >> >> >> >> >> >> Expected Results: >> >> Unique guid in all the messages. >> >> >> >> >> >> >> >> >> >> >> >> >> -------------------------------------------------------------------------------------------------------------------------------------- >> >> >> >> I understand that Fix value NONE in >> log4net.Appender.BufferingForwardingAppender >> >> will not fix any volatile variables , but making it all results in all my >> guids in all the 5 messages becoming same. >> >> >> >> Could anybody please tell me how to fix this issue? >> > > --089e01182d0a2d3bf20500aae077 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks a lot Sir, I will implement this idea and I will le= t you know if it works for me.


On Thu, Aug 14, 2014 at 1:45 PM, Michael Schall <mike.schall@gmail.com> wrote:
Try adding the thread name = to your conversion to ensure it is a different thread

<conversionPattern=C2=A0value=3D"%level %date= {yyyy-MM-dd'T'HH:mm:ss.fffzzz} %property{hostname}=C2=A0=C2=A0[%thread]=C2=A0= %property{guid} %message%newline"=C2=A0/>

It seems more likely that a thread is being reuse= d.

Mike


On T= hu, Aug 14, 2014 at 10:51 AM, Ananth Tatachar <ananth.tatachar@gma= il.com> wrote:

I am working with log4net version : 1.2.12.0 .

=C2=A0

I am getting inconsistent results , while using RollingFileAppender with BufferingForwardAppender.

My application i= s a multithreaded application. I spawned 5 threads Each will call the construct= or of MyClass and SomeFunction once.

My application&#= 39;s sertup is as follows:

=C2=A0

Web.config:

----------------= ---------------

=C2=A0<appender name=3D"RollingLocalFileAppender" type=3D"log4net.Appender.RollingFileAppender">
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <
file type=3D"log4net.Util.PatternString" value=3D"= ;C:\Logs\TFile.log" />
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <
rollingStyle<= span style=3D"color:black;background-image:initial;background-repeat:initia= l">
value=3D"Date" = />
=C2=A0=C2=A0=C2=A0=C2=A0 <
datePattern value=3D"yyyy-MM-dd" />
=C2=A0=C2=A0=C2=A0=C2=A0 <
maxSizeRollBackups<= span style=3D"color:black;background-image:initial;background-repeat:initia= l">
value=3D"10" />
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <
appendToFile<= span style=3D"color:black;background-image:initial;background-repeat:initia= l"> value=3D"true" = />
=C2=A0=C2=A0=C2=A0=C2=A0 <layout
type=3D"
log4net.Layout.PatternLayout<= /a>">
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <
conversi= onPattern value=3D"%= level %date{yyyy-MM-dd'T'HH:mm:
ss.fffzzz} %property{hostname}=C2=A0 %property{guid} %message%newline" />
=C2=A0=C2=A0=C2=A0=C2=A0 </
layout> =C2=A0=C2=A0=C2=A0 </appender>
=C2=A0=C2=A0=C2=A0 <
appender name=3D"BufferedFileAppender" type=3D"log4net.Appen= der.BufferingForwardingAppender">
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <
bufferSize value=3D"512"= />
=C2=A0=C2=A0=C2=A0=C2=A0 <evaluator
type=3D"log4net.Core.TimeEvaluator">

=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <interval val= ue=3D"10" />
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
<!--Sen= d buffered events immediately if 10 seconds pass-->
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </
evaluator>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <Fix value=3D"0" />
=C2=A0=C2=A0=C2=A0=C2=A0
<!--Buffering can have se= vere performance degradation if this is set to the default (ALL)-->
=C2=A0=C2=A0=C2=A0 </
appender><= /p>

=C2=A0

=C2=A0

Logging Class:

----------------= ----------

=C2=A0

Class MyClass

{

= public MyClass()

= {

L= og4net.ThreadContext.Properties["guid"] =3D Guid.NewGuid();

= }

= =C2=A0

= public void SomeFunction()

= {

I= log log =3D LogManager.GetLogger(typeof(MyClass));

L= og.Info("my message");

= }

= =C2=A0

}

=C2=A0

=C2=A0

Tfile.log(Result= )

----------------= ------

Observed Results= :

=C2=A0

INFO 2014-08-14T10:47:36.659-04:00 ANANTHTATACHAR MyAudsDigest [LQR-Y8c71EmtWl7ZqItYoQ] my message

INFO 2014-08-14T10:47:36.659-04:00=C2=A0 ANANTHTATACHAR MyAudsDigest=C2=A0 [9hDzS-_Su0SrEoXZF_aGMw] my message

INFO 2014-08-14T10:47:36.729-04:00 ANANTHTATACHAR MyAudsDigest=C2=A0 [GsxT7aTfNE= q1uIsqPYeZ5w]=C2=A0 my message

INFO 2014-08-14T10:47:36.789-04:00 ANANTHTATACHAR MyAudsDigest [9hDzS-_Su0SrEoXZF_aGMw] my message

INFO 2014-08-14T10:47:36.955-04:00 ANANTHTATACHAR MyAudsDigest=C2=A0 [9hDzS-_Su0= SrEoXZF_aGMw] my message

=C2=A0

=C2=A0

=C2=A0

Expected Results= :

Unique guid in a= ll the messages.

=C2=A0

=C2=A0

=C2=A0

=C2=A0

=C2=A0

----------------= ---------------------------------------------------------------------------= -------------------------------------------

=C2=A0

I understand tha= t Fix value=C2=A0 NONE in log4net.Appender.BufferingForwardingAppender= will not fix any volatile variables , but making it all results in all my g= uids in all the 5 messages becoming same.

=C2=A0

Could anybody pl= ease tell me how to fix this issue?



--089e01182d0a2d3bf20500aae077--