EventProviderTraceListener EventProviderTraceListener EventProviderTraceListener EventProviderTraceListener Class

Definition

A listener for TraceSource that writes events to the ETW subsytem.

public ref class EventProviderTraceListener : System::Diagnostics::TraceListener
public class EventProviderTraceListener : System.Diagnostics.TraceListener
type EventProviderTraceListener = class
    inherit TraceListener
Public Class EventProviderTraceListener
Inherits TraceListener
Inheritance
EventProviderTraceListenerEventProviderTraceListenerEventProviderTraceListenerEventProviderTraceListener

Examples

private static Guid providerId = new Guid("{B3F0C8FC-E8A8-4868-8901-1465E8A2F41B}");  

    EventProviderTraceListener listener = new EventProviderTraceListener(providerId.ToString(), "Test Listener", "::");  

    // You should use the All default level and control the level using the  
    // ETW session; otherwise, you may not log all the events requested by the  
    // session.  
    TraceSource source = new TraceSource("MyProvider", SourceLevels.All);  

    source.Listeners.Add(listener);  

    source.TraceData(TraceEventType.Warning | TraceEventType.Start, 2, new object[] { "abc", "def", true, 123 });  

    source.TraceEvent(TraceEventType.Warning, 12, "Provider guid: {0}", new object[] { providerId });  

    source.TraceInformation("string {0}, bool {1}, int {2}, ushort {3}", new object[] { "abc", false, 123, (UInt32)5 });  

Remarks

All event data (trace or debug) from the source event is written to the ETW subsystem as a string. The data elements are delimited using a comma. To specify a different delimiter, use the Delimiter property.

Adding the listener to System.Diagnostics.TraceSource registers the provider with the ETW subsystem. You must create an ETW trace session using the Logman.exe executable program (or something similar) to write the events to a log file.

You do not need a manifest to consume events from the listener because the event data is a single string.

When you call the System.Diagnostics.TraceSource methods to write events, you pass a System.Diagnostics.TraceEventType enumeration value. The enumeration contains both level and keyword values. When you enable a trace listener provider from an ETW session, the level value that you specify can be the value associated with one of the following System.Diagnostics.TraceEventType enumeration values:

  • Critical (value is 1)

  • Error (value is 2)

  • Information (value is 8)

  • Verbose (value is 16)

  • Warning (value is 4)

The keyword value that you specify for the session can be the value associated with one of the following System.Diagnostics.TraceEventType enumeration values:

  • Resume (value is 2,048)

  • Start (value is 256)

  • Stop (value is 512)

  • Suspend (value is 1,024)

  • Transfer (value is 4,096)

Constructors

EventProviderTraceListener(String) EventProviderTraceListener(String) EventProviderTraceListener(String) EventProviderTraceListener(String)

Initializes a new instance of the EventProviderTraceListener class using the specified provider identifier.

EventProviderTraceListener(String, String) EventProviderTraceListener(String, String) EventProviderTraceListener(String, String) EventProviderTraceListener(String, String)

Initializes a new instance of the EventProviderTraceListener class using the specified provider identifier and name of the listener.

EventProviderTraceListener(String, String, String) EventProviderTraceListener(String, String, String) EventProviderTraceListener(String, String, String) EventProviderTraceListener(String, String, String)

Initializes a new instance of the EventProviderTraceListener class using the specified provider identifier, name of the listener, and delimiter.

Properties

Attributes Attributes Attributes Attributes

Gets the custom trace listener attributes defined in the application configuration file.

(Inherited from TraceListener)
Delimiter Delimiter Delimiter Delimiter

Gets or sets the delimiter used to delimit the event data that is written to the ETW subsystem.

Filter Filter Filter Filter

Gets or sets the trace filter for the trace listener.

(Inherited from TraceListener)
IndentLevel IndentLevel IndentLevel IndentLevel

Gets or sets the indent level.

(Inherited from TraceListener)
IndentSize IndentSize IndentSize IndentSize

Gets or sets the number of spaces in an indent.

(Inherited from TraceListener)
IsThreadSafe IsThreadSafe IsThreadSafe IsThreadSafe

Gets a value indicating whether the trace listener is thread safe.

Name Name Name Name

Gets or sets a name for this TraceListener.

(Inherited from TraceListener)
NeedIndent NeedIndent NeedIndent NeedIndent

Gets or sets a value indicating whether to indent the output.

(Inherited from TraceListener)
TraceOutputOptions TraceOutputOptions TraceOutputOptions TraceOutputOptions

Gets or sets the trace output options.

(Inherited from TraceListener)

Methods

Close() Close() Close() Close()

Closes the output stream so it no longer receives tracing or debugging output.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the TraceListener.

(Inherited from TraceListener)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the TraceListener and optionally releases the managed resources.

(Inherited from TraceListener)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Fail(String) Fail(String) Fail(String) Fail(String)

Emits an error message to the listener you create when you implement the TraceListener class.

(Inherited from TraceListener)
Fail(String, String) Fail(String, String) Fail(String, String) Fail(String, String)

Emits an error message and a detailed error message to the listener you create when you implement the TraceListener class.

Flush() Flush() Flush() Flush()

Flushes the output buffer.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetSupportedAttributes() GetSupportedAttributes() GetSupportedAttributes() GetSupportedAttributes()

Gets the custom attributes supported by the trace listener.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
TraceData(TraceEventCache, String, TraceEventType, Int32, Object) TraceData(TraceEventCache, String, TraceEventType, Int32, Object) TraceData(TraceEventCache, String, TraceEventType, Int32, Object) TraceData(TraceEventCache, String, TraceEventType, Int32, Object)

Writes trace information, a data object and event information to the listener specific output.

TraceData(TraceEventCache, String, TraceEventType, Int32, Object[]) TraceData(TraceEventCache, String, TraceEventType, Int32, Object[]) TraceData(TraceEventCache, String, TraceEventType, Int32, Object[]) TraceData(TraceEventCache, String, TraceEventType, Int32, Object[])

Writes trace information, a data object and event information to the listener specific output.

TraceEvent(TraceEventCache, String, TraceEventType, Int32) TraceEvent(TraceEventCache, String, TraceEventType, Int32) TraceEvent(TraceEventCache, String, TraceEventType, Int32) TraceEvent(TraceEventCache, String, TraceEventType, Int32)

Writes trace and event information to the listener specific output.

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

Writes trace information, a message, and event information to the listener specific output.

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])

Writes trace information, a formatted array of objects and event information to the listener specific output.

TraceTransfer(TraceEventCache, String, Int32, String, Guid) TraceTransfer(TraceEventCache, String, Int32, String, Guid) TraceTransfer(TraceEventCache, String, Int32, String, Guid) TraceTransfer(TraceEventCache, String, Int32, String, Guid)

Writes trace information, a message, a related activity identity and event information to the listener specific output.

Write(Object) Write(Object) Write(Object) Write(Object)

Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class.

(Inherited from TraceListener)
Write(Object, String) Write(Object, String) Write(Object, String) Write(Object, String)

Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class.

(Inherited from TraceListener)
Write(String) Write(String) Write(String) Write(String)

When overridden in a derived class, writes the specified message to the listener you create in the derived class.

Write(String, String) Write(String, String) Write(String, String) Write(String, String)

Writes a category name and a message to the listener you create when you implement the TraceListener class.

(Inherited from TraceListener)
WriteIndent() WriteIndent() WriteIndent() WriteIndent()

Writes the indent to the listener you create when you implement this class, and resets the NeedIndent property to false.

(Inherited from TraceListener)
WriteLine(Object) WriteLine(Object) WriteLine(Object) WriteLine(Object)

Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator.

(Inherited from TraceListener)
WriteLine(Object, String) WriteLine(Object, String) WriteLine(Object, String) WriteLine(Object, String)

Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator.

(Inherited from TraceListener)
WriteLine(String) WriteLine(String) WriteLine(String) WriteLine(String)

When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator.

WriteLine(String, String) WriteLine(String, String) WriteLine(String, String) WriteLine(String, String)

Writes a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator.

(Inherited from TraceListener)

Applies to

See also