Freigeben über


Tracing Network Calls

Many common networking problems can be diagnosed by tracing System.Net events. This is often much easier than setting up packet captures or other software, particularly if you're working on a production machine. Since tracing is a part of the framework, it works almost everywhere just by dropping some additional configuration.

Here's an example of a complete configuration file for turning on System.Net tracing.

 <configuration>
 <system.diagnostics>
  <trace autoflush="true" />
  <sources>
   <source name="System.Net">
    <listeners>
     <add name="MyTrace"/>
    </listeners>
   </source>
  </sources>
  <sharedListeners>
   <add name="MyTrace" type="System.Diagnostics.TextWriterTraceListener" initializeData="trace.txt" />
  </sharedListeners>
  <switches>
   <add name="System.Net" value="Verbose" />
  </switches>
 </system.diagnostics>
</configuration>

You can also make the event source more specific by changing System.Net to one of System.Net.Sockets, System.Net.Cache, or System.Net.HttpListener.

Next time: You Are Here

Comments