SQL Profiler is a better solution, but if you need something more organic for your application that you could deploy and enable / disable during production, QA, etc ... then you could create a wrapper around System. Data.SqlClient Provider (for example, a provider registered in the configuration file as ... providerName = "System.Data.SqlClient").
This will essentially act as an interception proxy that will give you access to all information passing through the Provider (for example, between your application and the database client). This will allow you to pump what you need, intercept, modify, aggregate and / or enrich it. This is a bit more advanced, but it opens the door to capturing a range of information and can be inserted / replaced / deleted as a separate level of problems.
Joegeeky
source share