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 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,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pls also check ELMAH for error logging in 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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.