Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to log/trace all SQL queries made from a WCF service?

I'm working on a WCF service and I'd like to be able to get a dump of all the SQL queries it makes while I'm running it locally.

Currently its executing sprocs through numerous spread out SqlCommand's so I'd like to just get a list of every query that is ran.

Is there any sort of tool or configuration that I can setup to log this information? Normally I would just use something like SQL Profiler but I'm looking for something to run from the WCF perspective since I'm hitting an Azure database and SQL Profilier won't work with Azure (afaik)

like image 996
Allen Rice Avatar asked Sep 16 '11 20:09

Allen Rice


1 Answers

I'm not aware of a built in way of logging all sql code when using SqlCommand/SqlConnection.

I found this article on msdn: Data Access Tracing in SQL Server 2008 maybe it points you in the right direction.

A simpler but not very generic way i can imagine is to write a class that inherits from SqlCommand and delegates all methods to the real SqlCommand while adding some logging.

like image 197
Jan Avatar answered Oct 15 '22 05:10

Jan