C# .NET - Best Practices Error handling and logging

Asked By Giri Palakodeti on 21-May-09 04:27 PM

Can any one share the code or articles suggesting the best practices in error handling and logging C# .net apps.

thanks.

Re - Ravenet Rasaiyah replied to Giri Palakodeti on 21-May-09 10:08 PM

Hi

Yes error handling and log very important to all software. becuase of we are deploy our system in the production server, we need give error free and if any error or message we need log. then we can look the log and find out where error occurred.

Here couple of link to error handling and log.

Error handling best articles

http://www.codeproject.com/KB/cs/csmverrorhandling.aspx

http://www.codeguru.com/csharp/csharp/cs_syntax/errorhandling/article.php/c5873

Key points in exception handling.

http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspx

Log:

1. you can use the Log4net
http://www.codeproject.com/KB/trace/log4net_intro2.aspx

2.write log using MS enterprise libaray
http://www.programminghelp.com/programming/dotnet/c-microsoft-enterprise-library-logging/

3.write XML file log
http://www.codeproject.com/KB/cs/xml_error_log.aspx

I hope these best ways to both operation and implement using above sample code and key point your log and exception handling.

thank you