WriteEvent Method

EventSource.WriteEvent Method

.NET Framework (current version)
 

Writes an event by using the provided event identifier and optional arguments.

Namespace:   System.Diagnostics.Tracing
Assembly:  mscorlib (in mscorlib.dll)

NameDescription
System_CAPS_protmethodWriteEvent(Int32)

Writes an event by using the provided event identifier.

System_CAPS_protmethodWriteEvent(Int32, Byte[])

Writes an event by using the provided event identifier and byte array argument.

System_CAPS_protmethodWriteEvent(Int32, Int32)

Writes an event by using the provided event identifier and 32-bit integer argument.

System_CAPS_protmethodWriteEvent(Int32, Int32, Int32)

Writes an event by using the provided event identifier and 32-bit integer arguments.

System_CAPS_protmethodWriteEvent(Int32, Int32, Int32, Int32)

Writes an event by using the provided event identifier and 32-bit integer arguments.

System_CAPS_protmethodWriteEvent(Int32, Int32, String)

Writes an event by using the provided event identifier and 32-bit integer and string arguments.

System_CAPS_protmethodWriteEvent(Int32, Int64)

Writes an event by using the provided event identifier and 64-bit integer argument.

System_CAPS_protmethodWriteEvent(Int32, Int64, Byte[])

Writes the event data using the specified indentifier and 64-bit integer and byte array arguments.

System_CAPS_protmethodWriteEvent(Int32, Int64, Int64)

Writes an event by using the provided event identifier and 64-bit arguments.

System_CAPS_protmethodWriteEvent(Int32, Int64, Int64, Int64)

Writes an event by using the provided event identifier and 64-bit arguments.

System_CAPS_protmethodWriteEvent(Int32, Int64, String)

Writes an event by using the provided event identifier and 64-bit integer, and string arguments.

System_CAPS_protmethodWriteEvent(Int32, Object[])

Writes an event by using the provided event identifier and array of arguments.

System_CAPS_protmethodWriteEvent(Int32, String)

Writes an event by using the provided event identifier and string argument.

System_CAPS_protmethodWriteEvent(Int32, String, Int32)

Writes an event by using the provided event identifier and arguments.

System_CAPS_protmethodWriteEvent(Int32, String, Int32, Int32)

Writes an event by using the provided event identifier and arguments.

System_CAPS_protmethodWriteEvent(Int32, String, Int64)

Writes an event by using the provided event identifier and arguments.

System_CAPS_protmethodWriteEvent(Int32, String, String)

Writes an event by using the provided event identifier and string arguments.

System_CAPS_protmethodWriteEvent(Int32, String, String, String)

Writes an event by using the provided event identifier and string arguments.

The WriteEvent method provides overloads with combinations of string and integer arguments. If none of these combinations match the parameters for the call, the compiler uses the EventSource.WriteEvent(Int32, Object[]) overload, which is considerably slower than the other overloads. See the overload page for details.

In all cases, the eventid parameter should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
 base.WriteEvent(2, arg1);
}

You can also create a custom overload by using the WriteEventCore method.

Return to top
Show:
© 2016 Microsoft