This documentation is archived and is not being maintained.

EventLogTraceListener.TraceData Method (TraceEventCache, String, TraceEventType, Int32, Object)

Writes trace information, a data object and event information to the event log.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public override void TraceData (
	TraceEventCache eventCache,
	string source,
	TraceEventType severity,
	int id,
	Object data
/** @attribute ComVisibleAttribute(false) */ 
public void TraceData (
	TraceEventCache eventCache, 
	String source, 
	TraceEventType severity, 
	int id, 
	Object data
public override function TraceData (
	eventCache : TraceEventCache, 
	source : String, 
	severity : TraceEventType, 
	id : int, 
	data : Object
Not applicable.



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


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


One of the TraceEventType values specifying the type of event that has caused the trace.


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


A data object to write to the output file or stream.


The TraceData methods are not intended to be called by application code. They are called by methods of the Debug, Trace, and TraceSource classes to output trace data.

The TraceData method, like the TraceEvent method is intended for automated tools but also allows the attaching of additional objects, for example an exception instance, to the trace.

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 data object, formatted as a string, using the WriteEvent method.


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.

Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0