Common Logging 2.0 API Reference

CommonLoggingTraceListener Class

A TraceListener implementation sending all System.Diagnostics.Trace output to the Common.Logging infrastructure.

For a list of all members of this type, see CommonLoggingTraceListener Members .

System.Object
   MarshalByRefObject
      TraceListener
         CommonLoggingTraceListener

[Visual Basic]
Public Class CommonLoggingTraceListener
    Inherits TraceListener
[C#]
public class CommonLoggingTraceListener : TraceListener

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This listener captures all output sent by calls to System.Diagnostics.Trace and and TraceSource and sends it to an ILog instance.
The ILog instance to be used is obtained by calling GetLogger. The name of the logger is created by passing this listener's Name and any source or category passed into this listener (see WriteLine or TraceEvent for example).

Example

The snippet below shows how to add and configure this listener to your app.config:

[XML]
<system.diagnostics>
  <sharedListeners>
    <add name="Diagnostics"
         type="Common.Logging.Simple.CommonLoggingTraceListener, Common.Logging"
         initializeData="DefaultTraceEventType=Information; LoggerNameFormat={listenerName}.{sourceName}">
      <filter type="System.Diagnostics.EventTypeFilter" initializeData="Information"/>
    </add>
  </sharedListeners>
  <trace>
    <listeners>
      <add name="Diagnostics" />
    </listeners>
  </trace>
</system.diagnostics>

Requirements

Namespace: Common.Logging.Simple

Assembly: Common.Logging (in Common.Logging.dll)

See Also

CommonLoggingTraceListener Members | Common.Logging.Simple Namespace