Is it possible to write a global HttpModule in IIS and log all SQL request from all .NET applications running? If so where should I start?
I have seen some tools out there like http://newrelic.com that do this. Their tool logs all SQL and does not require me to put any special code in my apps. In fact it logs info from all the apps.
If you are going to log SQL requests, you need one of the following:
SQLHelper
with method ExecuteQuery
that calls SQLCommand.ExecuteQuery
, then takes the query passed in and logs it. Then you have to be disciplined in making sure every single SQL call is routed through your helper class.DataContext.Log
property.You can't capture all standard ADO.Net SQL requests from a .NET global HTTP Module because you don't have knowledge of or access to all of the current connections and commands that are executing.