-
Notifications
You must be signed in to change notification settings - Fork 19
TraceSources
Qactive provides the static Qactive.QactiveTraceSources
class, which offers TraceSource objects that can be used to log operations and data coming from Qactive providers.
Notifies when subscribing, unsubscribing, sending notifications, receiving notifications and iterating/invoking/subscribing via duplex callbacks.
The TCP provider also uses it to trace starting and stopping (services), connecting and disconnecting (clients).
Includes message details, data objects and errors. It's available client-side and server-side. Semantic logging is used to ensure that correlating the flow of data across the wire is easy. In a future build, Qactive will include a semantic parser as well.
Default level: Information
Note: To receive all notifications you must set the switch level to Verbose.
Notifies when expression trees are sent, received and rewritten.
Includes the full expression tree in human-readable form. It's available client-side and server-side.
Default level: Off
Note: To receive all notifications you must set the switch level to Verbose.
TraceSource
is built-in to the .NET FCL, so Qactive has no dependencies on any third-party logging libraries. If you prefer to use a third-party logging library, then simply define a class that derives from System.Diagnostics.TraceListener and write all events to the log class of your choice.
You can hook up an instance of your TraceListener to Qactive either programmatically or via your application's app.config file.
In the following example, a custom TraceListener called MyTraceListener is added to Qactive's sources and the switches are set to Verbose.
var listener = new MyTraceListener(myThirdPartyLogger);
Qactive.QactiveTraceSources.Qactive.Listeners.Add(listener);
Qactive.QactiveTraceSources.QactiveExpressions.Listeners.Add(listener);
Qactive.QactiveTraceSources.Qactive.Switch.Level = SourceLevels.Verbose;
Qactive.QactiveTraceSources.QactiveExpressions.Switch.Level = SourceLevels.Verbose;
In the following example, .NET's built-in DelimitedListTraceListener is used to log all events from Qactive.
As a bonus, the example also shows how to log System.Net socket and proxy events, including the raw message bytes, to the same log file. (You'll have to set the switch to Verbose to get the good stuff.)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sharedListeners>
<add name="LogFile" initializeData="Client.log" traceOutputOptions="ThreadId,DateTime" type="System.Diagnostics.DelimitedListTraceListener" delimiter=": " />
</sharedListeners>
<switches>
<!-- Off, Error, Warning, Information, Verbose -->
<add name="Qactive" value="Verbose" />
<add name="Qactive.Expressions" value="Off" />
<!-- Optional: Useful for logging WinSock TCP events and raw message bytes. To enable, set to Verbose. -->
<add name="Network" value="Warning" />
</switches>
<sources>
<!-- Qactive -->
<source name="Qactive" switchName="Qactive">
<listeners>
<add name="LogFile" />
</listeners>
</source>
<source name="Qactive.Expressions" switchName="Qactive.Expressions">
<listeners>
<add name="LogFile" />
</listeners>
</source>
<!-- System.Net -->
<source name="System.Net" tracemode="includehex" maxdatasize="1024" switchName="Network">
<listeners>
<add name="LogFile" />
</listeners>
</source>
<source name="System.Net.Sockets" switchName="Network">
<listeners>
<add name="LogFile" />
</listeners>
</source>
<source name="System.Net.Cache" switchName="Network">
<listeners>
<add name="LogFile" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>