pexxxy
pexxxy

Reputation: 509

Using a trace in SignalR

How can I utilize the Trace on a PersistenConnection?

public class Connection : PersistentConnection
{
    protected override Task OnConnectedAsync(IRequest request, string connectionId)
    {
        Trace.TraceInformation("ConnectedAsync ConnectionId:{0}", connectionId);
        return base.OnConnectedAsync(request, connectionId);
    }
}

How do I attach a Trace listener so the information in the TraceInformation call becomes visible?

Upvotes: 1

Views: 950

Answers (1)

Will
Will

Reputation: 1150

To turn on everything:

using Microsoft.AspNet.SignalR.Tracing;

public StockTickerHub(StockTicker stockTicker)
{
    _stockTicker = stockTicker;
    ITraceManager traceManager = GlobalHost.DependencyResolver.Resolve<ITraceManager>();
    traceManager.Switch.Level = SourceLevels.All;
}

Upvotes: 1

Related Questions