We are building asp.net application in which we want to log the received data (IP, http headers, etc) to database for every page request.
How to organize aps.net application, so that we are able to make a log to db even in case of exception?
Is this a good idea?
Should we write data to db in a new thread, so that it doesn't slow down the response?
If you are using IIS7, take a look at Failed Request Tracing. You can set up rules that will log all sorts of details about the request given certain error conditions. The XML file contains the request information, headers, and details about all of the HttpModules and HttpHandlers that processed the request.