2

I am currently attempting to write a custom appender for log4net. My Append method:

protected override void Append(LoggingEvent loggingEvent)
{
    ... stuff
}

I'd like to capture loggingEvent.ExceptionObject within the method. I can trigger the Append method with

throw new Exception("Test");

but the ExceptionObject is always null. Every other function of this program works; I can call RenderLoggingEvent(loggingEvent) and get the correct string back. I just can't get the exception.

Any ideas?

Nick Vaccaro
  • 5,428
  • 6
  • 38
  • 60

1 Answers1

4

Hoping this helps someone! : )

When catching the exception, I was using the Fatal(ex) method. This was converting the exception object to a string message. Changing the call to Fatal(ex, ex) or Fatal("Fatal: ", ex) correctly passed the exception to the custom appender.

Nick Vaccaro
  • 5,428
  • 6
  • 38
  • 60