Our implementation handled this by creating a custom ExceptionRenderer,
so all of the properties of the exception can be formatted correctly -
including inner exceptions.

The configuration calls out our custom Renderer:

<renderer
        renderingClass="MyApplication.log4net.ExceptionRenderer,
MyApplication.log4net "
        renderedClass="System.Exception, mscorlib" />

Here the implemented custom renderer is
MyApplication.log4net.ExceptionRenderer, and it implements
IObjectRenderer.  That leads to implementing RenderObject() where the
object is the exception instance.  In our implementation we loop through
the inner exceptions in reverse order.  We don't use the stack trace
property.

Then we implemented a custom layout, so when the LoggingEvent instance
is passed we can manage the exception string the way we want to, but
that's just icing on the cake.

Corey

-----Original Message-----
From: Widerberg Marcus [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 01, 2007 3:16 AM
To: Log4NET User
Subject: Logging stack trace

Hello everyone,

Is there a way to add a stack trace to each log event for a certain
appender layout?

I have an errorappender, and when it receives an event to log, I would
like it to log the whole stack trace as well.

This is for debug and test purposes.

/marcus

Reply via email to