Tracing on the client side

gustavo-armenta edited this page Apr 3, 2013 · 2 revisions

On a JavaScript client, enable tracing

.NET client

First, add a class to do application-level tracing anywhere from your project

    public class AppLogging
    {
        static TraceSource traceSource = new TraceSource("Application");

        internal static void WriteVerbose(string format, params object[] args)
        {
            traceSource.TraceEvent(TraceEventType.Verbose, 0, format, args);
        }

        internal static void WriteInformation(string format, params object[] args)
        {
            traceSource.TraceEvent(TraceEventType.Information, 0, format, args);
        }
    }

Second, enable tracing by adding this section on your App.config file

  <system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="default_traces" type="System.Diagnostics.TextWriterTraceListener" initializeData="default_traces.txt" />
      </listeners>
    </trace>
    <switches>
      <add name="SignalRSwitch" value="All" />
    </switches>
    <sources>

      <source name="Application" switchValue="All">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>

      <source name="System.Net" switchValue="All">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="System.Net.Http" switchValue="All">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="System.Net.Sockets" switchValue="All">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="System.Net.WebSockets" switchValue="All">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>

      <source name="SignalR.Connection">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="SignalR.PersistentConnection">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="SignalR.HubDispatcher">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="SignalR.Transports.WebSocketTransport">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="SignalR.Transports.ServerSentEventsTransport">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="SignalR.Transports.ForeverFrameTransport">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>
      <source name="SignalR.Transports.LongPollingTransport">
        <listeners>
          <add name="traces" />
        </listeners>
      </source>

    </sources>
    <sharedListeners>
      <add name="traces" type="System.Diagnostics.TextWriterTraceListener" initializeData="client_traces.txt" />
    </sharedListeners>
  </system.diagnostics>