8

How to log generated sql queries (without mysql profiler)?

I'm using Simple.Data.Mysql

casperOne
  • 73,706
  • 19
  • 184
  • 253
nidheeshdas
  • 1,097
  • 1
  • 11
  • 20

3 Answers3

13

You have a couple of choices here. You can either set up a trace listener like this and then yes it will show up in the VS output window.

<configuration>
   <system.diagnostics>
      <switches>
         <add name="Simple.Data" value="Info" />
      </switches>
   </system.diagnostics>
</configuration>

Or you can also have a look at the ExampleRunner and ExampleTestListener classes in Simple.Data.Sample for an example of setting it up in code.

Dan Maharry
  • 1,499
  • 2
  • 19
  • 35
  • Now that was directly useful. Thanks! – 8DH Jan 15 '13 at 14:06
  • 3
    In recent versions you need to write Information in value. See this line https://groups.google.com/forum/#!searchin/simpledata/trace/simpledata/xKQyUWLqa1Y/PwOqX1znzvwJ – oaamados Nov 13 '14 at 02:43
3

All generated SQL statements (plus parameter values) are written to Trace by default, so you can just hook up a Listener.

Mark Rendle
  • 9,274
  • 1
  • 32
  • 58
  • Could you elaborate a bit on this answer? Am I understanding this incorrectly, or is Simple.Data supposed to automatically log all queries to the Debug Output window in Visual Studio? I can't seem to get any queries to show up there and I can't find any info about enabling it. – enriquein Mar 23 '12 at 05:30
  • Are you on 0.16? There was a bug with the trace output in the previous version. – Mark Rendle Apr 06 '12 at 13:23
0

For newer versions of SimpleData, to attach to Trace use:

SimpleDataTraceSources.TraceSource.Listeners.Add(_myTraceListener);