Export (0) Print
Expand All

Configure the TraceListener in a Windows Azure Application

Updated: December 2, 2013

When using Trace, Debug and TraceSource, you must have a mechanism for collecting and recording the messages that are sent. Trace messages are received by listeners. The purpose of a listener is to collect, store, and route tracing messages. Listeners direct the tracing output to an appropriate target, such as a log, window, or text file. For Windows Azure Diagnostics, the DiagnosticMonitorTraceListener class is used. Before you complete the following procedure, you must initialize the Windows Azure diagnostic monitor. To do this, see Enabling Diagnostics in Windows Azure.

noteNote
If you use the templates that are provided by Visual Studio, the configuration of the listener has been added for you.

To add a trace listener

  1. Open the web.config or app.config file for your role.

  2. Add the following code to the file:

    
    <system.diagnostics>
       <trace>
          <listeners>
             <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, 
                Microsoft.WindowsAzure.Diagnostics, 
                Version=1.0.0.0, 
                Culture=neutral, 
                PublicKeyToken=31bf3856ad364e35"
                name="AzureDiagnostics">
                <filter type="" />
             </add>
          </listeners>
       </trace>
    </system.diagnostics>
    
  3. Save the file.

For more information about listeners, see Trace Listeners.

After you complete the steps to add the listener, you can add trace statements to your code. To do this, see Use Trace Messages in a Windows Azure Application.

See Also

Show:
© 2014 Microsoft