Log4net is a robust tool for logging to a variety of sources. Where I work, we use the Logging Application Blocks from the Enterprise Library. You can read up about these resources on their websites.
As for logging to XML files vs. databases, there are tradeoffs to each approach. Using local files reduces how many breakable components are required for a functioning application. Imagine that the database goes down, and your app tries to log to the database that the database went down... Hmmm.
On the other hand, logging to a database can dramatically improve your ability to query and gain intelligence on the nature of errors that get logged.
No one will be able to tell you absolutely what you should do; just weigh the tradeoffs and your expectations, and you'll be good to go.
If you want to go with some home-brewed error handling, you can tap into the Application_Error
method of your Global.asax and manually log members of the HttpContext.Current.AllErrors
property. You can also use the ClearError()
method on the context to wipe out the errors, and then redirect to a safe page if you want to log-and-continue.
Good luck!