EventLogTraceListener.TraceEvent EventLogTraceListener.TraceEvent EventLogTraceListener.TraceEvent EventLogTraceListener.TraceEvent Method

Definition

Writes event trace information to the event log.

Overloads

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 event log.

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 event log.

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 event log.

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ message);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string message);
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
Public Overrides Sub TraceEvent (eventCache As TraceEventCache, source As String, eventType As TraceEventType, id As Integer, message As String)
Parameters
eventCache
TraceEventCache TraceEventCache TraceEventCache TraceEventCache

An object that contains the current process ID, thread ID, and stack trace information.

source
String String String String

A name used to identify the output; typically the name of the application that generated the trace event.

severity
TraceEventType TraceEventType TraceEventType TraceEventType

One of the enumeration values that specifies the type of event that has caused the trace.

id
Int32 Int32 Int32 Int32

A numeric identifier for the event. The combination of source and id uniquely identifies an event.

message
String String String String

The trace message.

Exceptions

source is not specified.

-or-

The log entry string exceeds 32,766 characters.

Remarks

Important

The TraceEvent methods are not intended to be called by application code. These methods are called by methods of the Debug, Trace, and TraceSource classes to write trace data.

The TraceEvent method is intended to trace events that can be processed automatically by tools. For example a monitoring tool can notify an administrator if a specific event is traced by a specific source.

The eventCache and source parameters are used to determine if the event should be traced. id is used to create an EventInstance object and the TraceEventType is equated to an EventLogEntryType for the EntryType property. The EventInstance is written to the event log with the message data using the WriteEvent method.

Note

The maximum value of the id parameter is 65,535. If the id value specified is greater than 65,535, the maximum value is used.

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 event log.

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ format, ... cli::array <System::Object ^> ^ args);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object[] args);
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
Public Overrides Sub TraceEvent (eventCache As TraceEventCache, source As String, eventType As TraceEventType, id As Integer, format As String, ParamArray args As Object())
Parameters
eventCache
TraceEventCache TraceEventCache TraceEventCache TraceEventCache

An object that contains the current process ID, thread ID, and stack trace information.

source
String String String String

A name used to identify the output; typically the name of the application that generated the trace event.

severity
TraceEventType TraceEventType TraceEventType TraceEventType

One of the enumeration values that specifies the type of event that has caused the trace.

id
Int32 Int32 Int32 Int32

A numeric identifier for the event. The combination of source and id uniquely identifies an event.

format
String String String String

A format string that contains zero or more format items that correspond to objects in the args array.

args
Object[]

An object array containing zero or more objects to format.

Exceptions

source is not specified.

-or-

The log entry string exceeds 32,766 characters.

Remarks

Important

The TraceEvent methods are not intended to be called by application code. These methods are called by methods of the Debug, Trace, and TraceSource classes to write trace data.

The TraceEvent method is intended to trace events that can be processed automatically by tools. For example a monitoring tool can notify an administrator if a specific event is traced by a specific source.

The eventCache and source parameters are used to determine if the event should be traced. id is used to create an EventInstance object and the TraceEventType is equated to an EventLogEntryType for the EntryType property. The EventInstance is written to the event log, using the WriteEvent method, with the message obtained from the format and args parameters. The args object array is converted to a string using the Format method, passing the format string and args array to format the string as the message for the event log.

Note

The maximum value of the id parameter is 65,535. If the id value specified is greater than 65,535, the maximum value is used.

Applies to