Using database trace listener in your application is very easy. You need to follow these simple steps:


Step 1: Create database objects
You need a table in your database to store trace entries. You just need to execute a very small script which is available in source code at Scripts/tracelog.sql.
 
Step 2: Add trace listener in your application configuration file
You need to add database trace listener to your application and simplest way is to add is using application config file as follows:
<configuration>
  <system.diagnostics>
    <trace>
      <listeners>
        <add name="DBTraceListener" type="AdvancedTracing.DBTraceListener, AdvancedTracing"
initializeData="data source=SQLServer1;initial catalog=myDB;user id=u1234;password=p1234;">         </add>
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>


Step 3: Call Trace methods
Start calling Trace.WriteXXX method calls in your code and you are done.


Voila!