'Enable SignalR Trace in Windows Application
I tried to enable SignalR in a windows application following this link. https://docs.microsoft.com/en-us/aspnet/signalr/overview/testing-and-debugging/enabling-signalr-tracing I have added the following configuration for bouth app.config I have in my solution. It should work only in the project that uses SignalR I believe but it was not working so I have added the same block to app.config of main project also. It is not working because I couldn't find the trace file server_traces.txt in anywhere. I am not sure if it would be work just by adding this configuration or if is necessary to enable it on code.
<system.diagnostics>
<sharedListeners>
<add name="traces" type="System.Diagnostics.TextWriterTraceListener" initializeData="server_traces.txt" />
</sharedListeners>
<trace autoflush="true" />
<switches>
<add name="SignalRSwitch" value="All" />
</switches>
<sources>
<source name="SignalR.Connection">
<listeners>
<add name="traces" />
</listeners>
</source>
<source name="SignalR.PersistentConnection">
<listeners>
<add name="traces" />
</listeners>
</source>
<source name="SignalR.ReflectedHubDescriptorProvider">
<listeners>
<add name="traces" />
</listeners>
</source>
<source name="SignalR.HubDispatcher">
<listeners>
<add name="traces" />
</listeners>
</source>
<source name="SignalR.MessageBus">
<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>
<source name="SignalR.Transports.TransportHeartBeat">
<listeners>
<add name="traces" />
</listeners>
</source>
</sources>
</system.diagnostics>
And HubConnection trace is configured like this.
var tracePath = System.IO.Path.Combine("server_traces_{0}-{1}-{2}.txt", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day));
var writer = new System.IO.StreamWriter(tracePath);
writer.AutoFlush = true;
hubConnection.TraceLevel = TraceLevels.All;
hubConnection.TraceWriter = writer;
I have put the name different from what is on app.config to be sure "server_trace.txt" to verify if that configuration is ignored, and it seems that is it. Isn't it needed ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
