1

如何在 PersistenConnection 上使用 Trace?

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

如何附加 Trace 侦听器,以便 TraceInformation 调用中的信息变得可见?

4

1 回答 1

1

打开一切:

使用 Microsoft.AspNet.SignalR.Tracing;

public StockTickerHub(StockTicker stockTicker)
{
    _stockTicker = stockTicker;
    ITraceManager traceManager = GlobalHost.DependencyResolver.Resolve<ITraceManager>();
    traceManager.Switch.Level = SourceLevels.All;
}
于 2013-03-05T13:54:28.793 回答