You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Oren Eini <or...@we-can.co.il> on 2006/07/23 13:49:37 UTC

Log4net bug when using ThreadContext

The following code is failing, even though it looks like it can work:

 

MemoryAppender appender = new MemoryAppender();

ILog logger = LogManager.GetLogger("foo");

 

BasicConfigurator.Configure(appender);

 

using (log4net.ThreadContext.Stacks["1"].Push(null))

{

    logger.Error("Should work");

}

 

Debug.Assert(appender.GetEvents().Length != 0);


RE: Log4net bug when using ThreadContext

Posted by Ron Grabowski <ro...@yahoo.com>.
This issue was marked as Resolved on June 20, 2005:

 Exception rendering ThreadContextStack if null value pushed into stack
 http://issues.apache.org/jira/browse/LOG4NET-35

--- Oren Eini <or...@we-can.co.il> wrote:

> 1.2.9, I think (not at the office right now).
> It doesn't throw an exception, but it stopps logging.
> 
> ________________________________
> 
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com]
> Sent: Sun 2006-07-23 22:42
> To: Log4NET User
> Subject: Re: Log4net bug when using ThreadContext
> 
> 
> 
> This code:
> 
>  // Console Application
>  ConsoleAppender consoleAppender = new ConsoleAppender();
>  consoleAppender.Layout =
>   new PatternLayout("%level %message %property");
>  BasicConfigurator.Configure(consoleAppender);
>  ILog log = LogManager.GetLogger(typeof(Class1));
>  using (ThreadContext.Stacks["1"].Push(null))
>  {
>   log.Error("Should work");
>  }
> 
> throws a NullReferenceException in log4net 1.2.9 beta
> (log4net.Util.StackFrame.get_FullMessage()). It does not throw an
> exception in 1.2.10.
> 
> What version of log4net are you using? Are you getting an exception
> when the code fails?
> 
> --- Oren Eini <or...@we-can.co.il> wrote:
> 
> > The following code is failing, even though it looks like it can
> work:
> >
> > 
> >
> > MemoryAppender appender = new MemoryAppender();
> >
> > ILog logger = LogManager.GetLogger("foo");
> >
> > 
> >
> > BasicConfigurator.Configure(appender);
> >
> > 
> >
> > using (log4net.ThreadContext.Stacks["1"].Push(null))
> >
> > {
> >
> >     logger.Error("Should work");
> >
> > }
> >
> > 
> >
> > Debug.Assert(appender.GetEvents().Length != 0);
> >
> >
> 
> 
> 
> 


RE: Log4net bug when using ThreadContext

Posted by Oren Eini <or...@we-can.co.il>.
1.2.9, I think (not at the office right now).
It doesn't throw an exception, but it stopps logging.

________________________________

From: Ron Grabowski [mailto:rongrabowski@yahoo.com]
Sent: Sun 2006-07-23 22:42
To: Log4NET User
Subject: Re: Log4net bug when using ThreadContext



This code:

 // Console Application
 ConsoleAppender consoleAppender = new ConsoleAppender();
 consoleAppender.Layout =
  new PatternLayout("%level %message %property");
 BasicConfigurator.Configure(consoleAppender);
 ILog log = LogManager.GetLogger(typeof(Class1));
 using (ThreadContext.Stacks["1"].Push(null))
 {
  log.Error("Should work");
 }

throws a NullReferenceException in log4net 1.2.9 beta
(log4net.Util.StackFrame.get_FullMessage()). It does not throw an
exception in 1.2.10.

What version of log4net are you using? Are you getting an exception
when the code fails?

--- Oren Eini <or...@we-can.co.il> wrote:

> The following code is failing, even though it looks like it can work:
>
> 
>
> MemoryAppender appender = new MemoryAppender();
>
> ILog logger = LogManager.GetLogger("foo");
>
> 
>
> BasicConfigurator.Configure(appender);
>
> 
>
> using (log4net.ThreadContext.Stacks["1"].Push(null))
>
> {
>
>     logger.Error("Should work");
>
> }
>
> 
>
> Debug.Assert(appender.GetEvents().Length != 0);
>
>




Re: Log4net bug when using ThreadContext

Posted by Ron Grabowski <ro...@yahoo.com>.
This code:

 // Console Application
 ConsoleAppender consoleAppender = new ConsoleAppender();
 consoleAppender.Layout = 
  new PatternLayout("%level %message %property");
 BasicConfigurator.Configure(consoleAppender);
 ILog log = LogManager.GetLogger(typeof(Class1));
 using (ThreadContext.Stacks["1"].Push(null))
 {
  log.Error("Should work");
 }

throws a NullReferenceException in log4net 1.2.9 beta
(log4net.Util.StackFrame.get_FullMessage()). It does not throw an
exception in 1.2.10. 

What version of log4net are you using? Are you getting an exception
when the code fails?

--- Oren Eini <or...@we-can.co.il> wrote:

> The following code is failing, even though it looks like it can work:
> 
>  
> 
> MemoryAppender appender = new MemoryAppender();
> 
> ILog logger = LogManager.GetLogger("foo");
> 
>  
> 
> BasicConfigurator.Configure(appender);
> 
>  
> 
> using (log4net.ThreadContext.Stacks["1"].Push(null))
> 
> {
> 
>     logger.Error("Should work");
> 
> }
> 
>  
> 
> Debug.Assert(appender.GetEvents().Length != 0);
> 
>