• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 675
  • Last Modified:

Best practices for Error Logging in ASP.NET

I was wondering what the best practices for error logging are for a web application developed using asp.net 4.0. This is both at an application level as well as at the page level.
Should we be wrtiting errors to text files or should we be writing errors to database tables. Would like to understand the pros and cons of using each approach. Also if there is something available within the framework that we could use right off the bat.

Any help would be appreciated,
1 Solution
Jitendra PatilSr.Software EngineerCommented:
hi you can refer the below links
Error Logging in ASP.NET
Error Handling in .Net with Example
hope this helps.
pls also check ELMAH for error logging in asp.net you can integrate it with your website and then it will even send you mails for errors

check out

The issue is quite simple:

database logging only works if the database connection is fine.  So it will not log any connection errors.

textfile logging requires write permissions, which is not always that simple to set. So it will not log any issues with write permissions.

All in all, I prefer textfile logging, because the required permissions are easily checked and every error can be logged.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now