Redigera

Dela via


EventProvider.WriteMessageEvent Method

Definition

Writes an event that contains a string as its data.

Overloads

WriteMessageEvent(String)

Writes an event that contains a string as its data.

WriteMessageEvent(String, Byte, Int64)

Writes an event that contains a string as its data if the level and keyword value match the events requested by the session.

Remarks

These methods do not require a manifest to consume the event.

WriteMessageEvent(String)

Writes an event that contains a string as its data.

public:
 bool WriteMessageEvent(System::String ^ eventMessage);
public bool WriteMessageEvent (string eventMessage);
member this.WriteMessageEvent : string -> bool
Public Function WriteMessageEvent (eventMessage As String) As Boolean

Parameters

eventMessage
String

String to write as the event data.

Returns

Is true if the event is written; otherwise, false. If false, call the GetLastWriteEventError() method to determine the cause of the failure.

Exceptions

If eventMessage is null.

Examples

if (!provider.WriteMessageEvent("Event string."))  
    Console.WriteLine(EventProvider.GetLastWriteEventError());  

Remarks

The maximum string length is limited to 64 KB minus the size of the event headers. The event size is less if the session's buffer size is less and the session includes extended data items with the event.

Applies to

WriteMessageEvent(String, Byte, Int64)

Writes an event that contains a string as its data if the level and keyword value match the events requested by the session.

public:
 bool WriteMessageEvent(System::String ^ eventMessage, System::Byte eventLevel, long eventKeywords);
[System.Security.SecurityCritical]
public bool WriteMessageEvent (string eventMessage, byte eventLevel, long eventKeywords);
[<System.Security.SecurityCritical>]
member this.WriteMessageEvent : string * byte * int64 -> bool
Public Function WriteMessageEvent (eventMessage As String, eventLevel As Byte, eventKeywords As Long) As Boolean

Parameters

eventMessage
String

String to write as the event data.

eventLevel
Byte

Level of detail included in the event. If the provider uses a manifest to define the event, set this value to the same level defined in the manifest.

eventKeywords
Int64

Bit mask that specifies the event category. If the provider uses a manifest to define the event, set this value to the same keyword mask defined in the manifest.

Returns

Is true if the event is written; otherwise, false. If false, call the GetLastWriteEventError() method to determine the cause of the failure.

Attributes

Exceptions

If eventMessage is null.

Examples

// Calling this method with level and keyword set to zero is the same  
// as calling WriteMessageEvent(string); the event is always written.  
if (!provider.WriteMessageEvent("Event string.", 0, 0))  
    Console.WriteLine(EventProvider.GetLastWriteEventError());  

// Event is written if the level value of the session is less than or equal to 3, and bit 1 of the session  
// keyword bit-mask is set.  
if (!provider.WriteMessageEvent("Event string.", 3, 2))  
    Console.WriteLine(EventProvider.GetLastWriteEventError());  

Remarks

The maximum string length is limited to 64 KB minus the size of the event headers. The event size is less if the session's buffer size is less and the session includes extended data items with the event.

Applies to