Nice to format exception to string

I would like to create a nicely formatted logging exception line. When doing this from silverlight, options like nlog ( not yet ), log4net is not an option.

Anyone who has seen the code creates something like:

ExceptionType: xxxx
Message: xxxx
StackTrace: XXX
InnerException
    ExceptionType: xxxx
    Message: xxxx
    StackTrace: XXX

I am writing now myself, just hoping that the code there will do something nicer.

UPDATE : I was just about to close this q, because I came to the same conclusion as Zack, but I'm not going to deprive Zach of points! :)

.ToString () looks like this:

System.Exception: I can't handle this ---> System.DivideByZeroException: Attempted to divide by zero.
   at MuckingAround.RussTest_Click (Object sender, RoutedEventArgs e)
   --- End of inner exception stack trace ---
   at MuckingAround.RussTest_Click (Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick ()
   at System.Windows.Controls.Button.OnClick ()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp (MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp (Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent (IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
+5
source share
3 answers

You should get all this by simply calling the .ToString()exception method . We use this to record information, and you get everything that I suppose you ask. See the MSDN for more information System.Exception.ToString().

+13

: EntLib .

0

Also, see what's included in the Enterprise Library 5.0 Silverlight Integration Pack , which will address many of these cross-cutting issues for LOB developers, including logging and exception handling.

Feel free to comment on the features and also vote!

0
source

All Articles