logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominik Psenner <dpsen...@gmail.com>
Subject Re: Log4net.ThreadContext.Properties Having stale data. How to resolve it?
Date Thu, 24 Jul 2014 06:40:09 GMT
Hi Ananth Tatachar,

I'm having a hard time understanding your problem. Can you provide us a
sample application including all the code together with both a broken
sample output and a expected sample output? It would also be interesting
which exact version of log4net you are using.

Best regards



2014-07-24 2:31 GMT+02:00 Ananth Tatachar <ananth.tatachar@gmail.com>:

>
>
> ---------- Forwarded message ----------
> From: Ananth Tatachar <ananth.tatachar@gmail.com>
> Date: Wed, Jul 23, 2014 at 8:24 PM
> Subject: Log4net.ThreadContext.Properties Having stale data. How to
> resolve it?
> To: log4net-user@logging.apache.org
>
>
> I am using a RollingFileAppender , and my own custom layout. My
> application is multithreaded. Each thread will generate unique random data
> and is supposed to log it using log4net framework. However if I create
> multiple threads in quick succession I notice stale data in my logs , this
> goes away if each thread sleeps for 50 ms before logging. I am not able to
> figure out a solution to this issue or find its cause please do help me.
>
> My logging function looks like this:
>
>
>     log4net.ThreadContext.properties["randomGeneratedData"] =
> randomGeneratedData;
>     private ILog myLog =
>            LogManager.GetLogger(typeof(LogTest));
>     using (log4net.NDC.Push("ndcTest1"))
>     {
>         using (log4net.NDC.Push("ndcTest2"))
>             {
>                 myLog.Info("myLogTest");
>             }
>     }
>
>
>
>
>
> Result of logging:
>
>         NDC = "ndcTest1 ndcTest2" , randomGeneratedData = rad1
>        NDC = "ndcTest1 ndcTest2" , randomGeneratedData = rad2
>        NDC = "", randomGeneratedData = rad2
>
> and so on ...
>
>
> I tried to clear log4net.ThreadContext.Properties before filling it again
> , but it was of no use. Please help.
>
>


-- 
Dominik Psenner

Mime
View raw message