Edit

Share via


FileLogTraceListener.TraceEvent Method

Definition

Writes trace and event information to the output file or stream.

Overloads

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

Writes trace information, a message and event information to the output file or stream.

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

Writes trace information, a formatted array of objects, and event information to the output file or stream.

Remarks

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

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

Writes trace information, a message and event information to the output file or stream.

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ message);
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

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

source
String

A name of the trace source that invoked this method.

eventType
TraceEventType

One of the TraceEventType enumeration values.

id
Int32

A numeric identifier for the event.

message
String

A message to write.

Remarks

This method:

  1. Formats the data and context information for output.

  2. Creates a new log file, if necessary.

  3. Writes the information to the log file.

For more information on creating new log files, see FullLogFileName.

This table lists the output fields in the order in which they appear. The fields are delimited by the string that the Delimiter property specifies, and are followed by a line terminator.

Field Output condition Description
source Always. The value of name.
severity Always. The enumeration-value name of eventType.
id Always. The string representation of id.
message Always. The value of message.
callStack When the Callstack flag is set in the TraceOutputOptions property. The Callstack property of eventCache.
CorrelationID When the LogicalOperationStack flag is set in the TraceOutputOptions property. The ThreadId property of eventCache.
DateTime When the DateTime flag is set in the TraceOutputOptions property. The string representation of the DateTime property of eventCache. The invariant culture is used for the string conversion.
ProcessID When the ProcessId flag is set in the TraceOutputOptions property. The string representation of the ProcessId property of eventCache. The invariant culture is used for the string conversion.
ThreadID When the ThreadId flag is set in the TraceOutputOptions property. The ThreadId property of eventCache.
Timestamp When the Timestamp flag is set in the TraceOutputOptions property. The string representation of the Timestamp property of eventCache. The invariant culture is used for the string conversion.
HostName When the IncludeHostName property is True. The name of the computer.

See also

Applies to

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

Writes trace information, a formatted array of objects, and event information to the output file or stream.

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);
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

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

source
String

A name of the trace source that invoked this method.

eventType
TraceEventType

One of the TraceEventType enumeration values.

id
Int32

A numeric identifier for the event.

format
String

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

args
Object[]

An Object array containing zero or more objects to format.

Remarks

This method:

  1. Formats the data and context information for output.

  2. Creates a new a new log file, if necessary.

  3. Writes the information to the log file.

For more information on creating new log file, see FullLogFileName.

This table lists the output fields in the order in which they appear. The fields are delimited by the string that the Delimiter property specifies, and followed by a line terminator.

Field Output condition Description
source Always The value of name.
severity Always The enumeration-value name of eventType.
id Always The string representation of id.
message Always The data in args formatted with the format string and using the invariant culture for string conversions.
callStack When the Callstack flag is set in the TraceOutputOptions property. The Callstack property of eventCache.
CorrelationID When the LogicalOperationStack flag is set in the TraceOutputOptions property. The ThreadId property of eventCache.
DateTime When the DateTime flag is set in the TraceOutputOptions property. The string representation of the DateTime property of eventCache. The invariant culture is used for the string conversion.
ProcessID When the ProcessId flag is set in the TraceOutputOptions property. The string representation of the ProcessId property of eventCache. The invariant culture is used for the string conversion.
ThreadID When the ThreadId flag is set in the TraceOutputOptions property. The ThreadId property of eventCache.
Timestamp When the Timestamp flag is set in the TraceOutputOptions property. The string representation of the Timestamp property of eventCache. The invariant culture is used for the string conversion.
HostName When the IncludeHostName property is True. The name of the computer.

See also

Applies to