Search This Blog

Friday, January 3, 2014

Tracing in Application

The easiest  way to trace the application is Add the trace listner in web/app config file.
here is sample code to add trace in application.

<configuration>
  <system.diagnostics>
    <trace autoflush ="true" indentsize="4">
      <listeners>
        <add name ="TestListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="application.log" />
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>
 
use Trace.Write to write into log file.
it will create a log file in application, trace is the easiest why to track the bug/exception in application.

No comments:

Post a Comment