Thursday, September 30, 2010

Log Exception.ToString(); never log only Exception.Message!

When you are trying to log an exception, don't forget that you should always log
Exception.ToString();

And never use
 Exception.Message

The first snippet of code gives you more information about the exception like Stack trace, Inner exception and Message.
If you only log Exception.Message, you'll only have something like "Object reference not set to an instance of an object".

No comments:

Post a Comment