- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Exception Handling Best Practices
The best practices for Exception Handling in C# are based on logging the exception. The log should be to logging library to keep a record of the exceptions.
The following are the best practices you should follow while handling exceptions in C# −
- Log exceptions using log4net, NLog, and other frameworks used for the same purpose. Log exceptions to a file and send the log to various other targets like a database, email, etc.
- You should log every exception in your application. They help in finding the problems in the LOC.
- With logging exceptions, you need to also log the contextual details useful for troubleshooting exceptions.
- Use an exception-monitoring tool to manage and log exceptions. That would allow you to keep all the exceptions at a centralized location and uniquely identify it.
- With that, you will also get an option to view and search all exceptions added on all servers and applications.
Advertisements