Enabling Network Tracing in .Net

Enabling Network Tracing in .Net

Added by Nasir Mahmood updated on Friday, November 17, 2017

Problem:

Many times we want to enable Network tracing in our dot net application to test application's performance. In this tutorial we will learn how to achieve this.

Using Web.config:

Network tracing provides access to information about method invocations and network traffic generated by a managed application. You must complete the following tasks to enable network tracing in your application:

Now add following code to application configuration file.

				

<system.diagnostics>
  <sources>
    <source name="System.Net" tracemode="includehex" maxdatasize="1024">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
    <source name="System.Net.Sockets">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
    <source name="System.Net.Cache">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
  </sources>
  <switches>
    <add name="System.Net" value="Verbose"/>
    <add name="System.Net.Sockets" value="Verbose"/>
    <add name="System.Net.Cache" value="Verbose"/>
  </switches>
  <sharedListeners>
    <add name="System.Net" type="System.Diagnostics.TextWriterTraceListener"
					 initializeData="c:\trace.log" />
  </sharedListeners>
  <trace autoflush="true"/>
</system.diagnostics>	
				

Now after debuging application we can see our trace file at path c:\trace.log.

For more information Configure Network Tracing

Related Tags

About

29 Tutorials
25 Snippets
6 Products

More

Contact Us

Contact us

Stay Connected