This sample demonstrates a System.Diagnostics.TraceListener which sends tracing information over the Windows Azure Service Bus to a remote receiver.

Prerequisites

If you haven't already done so, please read the release notes document that explains how to sign up for a Windows Azure account and how to configure your environment.

Running the Sample

First configure the application configuration (App.config) files of both the TraceConsole and TraceTest applications (see below). Start the TraceConsole application, then start the TraceTest application. The TraceTest application sends tracing information (via the Service Bus). The TraceConsole application receives this information and outputs it to the console. As an additional test, you can run the TraceConsole and TraceTest applications on different computers, or even on different networks.

TraceListener

In the TraceListener project a System.Diagnostics.TraceListener is defined. This listener sends tracing information over the Service Bus using the NetEventRelayBinding.

TraceConsole

The TraceConsole listens on a NetEventRelayBinding URI and prints the trace information it receives to the console.

You must configure the TraceConsole App.config file with your account information. The following example demonstrates this configuration:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="CloudTraceServicePath" value="samples/traces"/>
        <add key="CloudTraceServiceNamespace" value="myexample"/>
        <add key="CloudTraceIssuerName" value="myexample"/>
        <add key="CloudTraceIssuerSecret" value="aflqn+lr64pVtENA/UayGC49+ImzwY5EmJHeAQJSnSY="/>
    </appSettings>
</configuration>

TraceTest

The TraceTest project adds the CloudTrace listener to its list of active trace listeners and generates sample tracing data.

You must add your account information to the TraceTest App.config file. You can refer to the TraceListener configuration file. The following example demonstrates this configuration:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="CloudTraceServicePath" value="samples/traces"/>
        <add key="CloudTraceServiceNamespace" value="myexample"/>
        <add key="CloudTraceIssuerName" value="myexample"/>
        <add key="CloudTraceIssuerSecret" value="aflqn+lr64pVtENA/UayGC49+ImzwY5EmJHeAQJSnSY="/>
</appSettings>

<system.diagnostics>
    <trace>
        <listeners>
            <add name="CloudTrace" type="Microsoft.ServiceBus.Samples.CloudTraceListener,Microsoft.ServiceBus.Samples.CloudTraceListener"></add>
        </listeners>
    </trace>
</system.diagnostics>

</configuration>

 


Did you find this information useful? Please send your suggestions and comments about the documentation.