Reflectoring around shows that Logging.On is enabled by 'flag' in
s_WebTraceSource = new NclTraceSource("System.Net");
s_HttpListenerTraceSource = new NclTraceSource("System.Net.HttpListener");
s_SocketsTraceSource = new NclTraceSource("System.Net.Sockets");
s_CacheTraceSource = new NclTraceSource("System.Net.Cache");
try
{
flag = ((s_WebTraceSource.Switch.ShouldTrace(TraceEventType.Critical) || s_HttpListenerTraceSource.Switch.ShouldTrace(TraceEventType.Critical)) || s_SocketsTraceSource.Switch.ShouldTrace(TraceEventType.Critical)) || s_CacheTraceSource.Switch.ShouldTrace(TraceEventType.Critical);
}
This implies it's using standard tracing and just checking to see if at least the "Critical" level is being watched. A sample of how to use this can be found in the "Debugging a Sockets Application" section of this MSDN article as in:
<configuration>
<system.diagnostics>
<sources>
<source name="System.Net.Sockets">
<listeners>
<add name="Sockets"/>
</listeners>
</source>
</sources>
<switches>
<add name="System.Net.Sockets" value="31" />
</switches>
<sharedListeners>
<add name="Sockets" type="System.Diagnostics.TextWriterTraceListener"
initializeData="Sockets.log"/>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
As the article explains, the switch values are bitwise OR's of these five values:
- Network traffic (0x10)
- Method entry and exit (0x8)
- Warnings (0x4)
- Errors (0x2)
- Critical events (0x1).
If you OR all of these (0x10 | 0x8 | 0x4 | 0x2 | 0x1) you get 0x1F which is "31" in decimal as seen above.
Details on setting using an application configuration file can be found here. It should just be a matter of creating an app.config or web.config file similiar to the one above for the source(s) that you'll use.