logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Problems with ThreadContext and TransactionScope
Date Wed, 26 Aug 2015 23:43:20 GMT
Do you get the same error when you use LogicalThreadContext?
      From: Ílson Bolzan <ilbolzan@gmail.com>
 To: Log4NET User <log4net-user@logging.apache.org> 
 Sent: Wednesday, August 26, 2015 1:18 PM
 Subject: Problems with ThreadContext and TransactionScope
Has anyone tried to stack contexts and use Transaction scope at the same time?

I'm trying something like this:
using (log4net.ThreadContext.Stacks["contextLog"].Push("Saving Data"))
	log.Info("Starting transaction");
	using (var ts = new TransactionScope(TransactionScopeOption.Required))
		log.Info("Inside Transaction");
and I'm getting that result:

2015/42/26 13:42:10,841 INFO  [Saving Data] Starting transaction 
2015/42/26 13:42:10,870 INFO  [(null)] Inside Transaction

I was expecting it to have [Saving Data] instead of [(null)]  on the second line.

It appears to loose access to the log4net ThreadContext Stack as soon as it enters a transaction.

Do you know how to avoid this?

Thank you so much.

View raw message