Logging Unhandled versus handled exceptions.Best practice

Discussion in 'ASP.NET 2.0' started by minnug, Jan 28, 2008.

  1. Could you tell me what you consider to be best practise. I have set up unhandled exceptions in my web site
    to be notified by email. Handled exception blocks try catch finally still remain in my programs e.g database connections. What is best practice for a production web site. Should I remove try catch and allow these exceptions to be handled as unhandled exceptions or should I write seperate email notifications for the handled exceptions? Or is there a better way?

    Regards Steve
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    I would handle the exception within the application_onerror routine in the global.asax file.


    This way, it will catch anything that you forgot to include in a catch block.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. I recommend using ELMAH (www.elmah.org)

    You just drop a .dll in your bin folder and add a couple of tables to your DB and it automatically logs unhandled exceptions with all of the details. I've used it in many projects.
     

Share This Page