Code Coverage by Clover.NET

Custom exception layout renderer isn't working

View: New views
1 Messages — Rating Filter:   Alert me  

Custom exception layout renderer isn't working

by cmshawn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My application has a custom Exception that includes a few extra properties (like .Server to identify the name of the server that encountered the exception).

I've written a custom layout renderer with the ExceptionLayoutRenderer as it's base class:

 C#
 [LayoutRenderer("myexception")]
 public sealed class MyExceptionLayoutRenderer : ExceptionLayoutRenderer {
 ...
 }

The Append method parses the Format property.  Any custom properties it finds get added to the StringBuilder, and all the others get passed along to the base class to be handled as usual.

I've added the assembly that contains this class to the extensions section of the nlog configuration, and I've added the following as the layout attribute for my target:

 layout="${myexception:format=server}"

But when I call logger.ErrorException("test", myEx) all I get is a blank line in the windows event log.  Anybody have any idea what I might be missing here?
LightInTheBox - Buy quality products at wholesale price