tags:

views:

72

answers:

1

Is there a way to intercept/log all database calls from a .Net Assembly. The primary purpose is to log all TSQL statements generated and send to SQL Server database from any of the businss logic layer assembly. This mechanism should be available at global level and not required to be applied at each assembly. This mechanism should be unlike SQL profiler in that it should provided with a stack trace which generated the SQL statement.

The purpose of such mechanism is to log all sql statments generated by an application and apply some analysis on it. This question is in regards to ADO.net technology.

A: 

The database is capable of logging all queries regardless of what application makes the query. Take a look here.

Fragsworth
I am not looking on the database side. How would you log the stack trace in that case?I want to log the SQL statements along with the .net stack trace of it.
Anand Patel
You need appropriate permissions to set this up. Therefore not possible in production scenario
Alexander Abramov