Common Logging 2.0 API Reference

CommonLoggingEntlibTraceListener Class

Use this TraceListener implementation to route all Entlib logging events to the Common.Logging infrastructure.

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

System.Object
   MarshalByRefObject
      TraceListener
         FormattedTraceListenerBase
            CommonLoggingEntlibTraceListener

[Visual Basic]
Public Class CommonLoggingEntlibTraceListener
    Inherits FormattedTraceListenerBase
[C#]
public class CommonLoggingEntlibTraceListener : FormattedTraceListenerBase

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

See CommonLoggingEntlibTraceListenerData for a list of properties to configure.

Example

To route all Logger events to Common.Logging, configure CommonLoggingEntlibTraceListener:

[XML]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="loggingConfiguration" 
type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, 
Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a" />
    </configSections>
    <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
        defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
        <listeners>
            <add name="Common.Logging Listener" 
                 type="Common.Logging.EntLib.CommonLoggingEntlibTraceListener, Common.Logging.EntLib"
                 listenerDataType="Common.Logging.EntLib.CommonLoggingEntlibTraceListenerData, 
Common.Logging.EntLib"
                 loggerNameFormat="{listenerName}.{sourceName}"
                 formatter="Text Formatter"
                 />
        </listeners>
        <formatters>
            <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: 
{category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: 
{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: 
{appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 
Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: 
{dictionary({key} - {value}&#xD;&#xA;)}"
                type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, 
Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a"
                name="Text Formatter" />
        </formatters>
        <specialSources>
            <allEvents switchValue="All" name="All Events">
                <listeners>
                    <add name="Test Capturing Listener" />
                </listeners>
            </allEvents>
        </specialSources>
    </loggingConfiguration>
</configuration>

Requirements

Namespace: Common.Logging.EntLib

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

See Also

CommonLoggingEntlibTraceListener Members | Common.Logging.EntLib Namespace