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: Log4net bug when using ThreadContext
Date Sun, 23 Jul 2006 19:42:27 GMT
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 <orene@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);
> 
> 


Mime
View raw message