Hi Ron,

You were right about LogicalThreadContext. It worked.

Also, I was wrong about the problem. It has to do with
System.Threading.Tasks and not with TransactionScope.

http://stackoverflow.com/questions/32233419/conflict-between-log4nets-threadcontext-and-task/

Thank you.

On Wed, Aug 26, 2015 at 8:43 PM, Ron Grabowski <rongrabow...@yahoo.com>
wrote:

> Do you get the same error when you use LogicalThreadContext?
>
> ------------------------------
> *From:* Ílson Bolzan <ilbol...@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.
>
>
>
>
>

Reply via email to