Redigere

Condividi tramite


EventAttribute.Message Property

Definition

Gets or sets the message for the event.

public:
 property System::String ^ Message { System::String ^ get(); void set(System::String ^ value); };
public string Message { get; set; }
public string? Message { get; set; }
member this.Message : string with get, set
Public Property Message As String

Property Value

The message for the event.

Examples

The following example shows how to use the Message property to specify an event message. This code example is part of a larger example provided for the EventSource class.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
<[Event](1, Message:="Application Failure: {0}", Level:=EventLevel.Error, Keywords:=Keywords.Diagnostic)> _
Public Sub Failure(ByVal message As String)
    WriteEvent(1, message)
End Sub

Remarks

You can use standard .NET substitution operators (for example, {1}) in the string. They will be replaced with the string representation of the corresponding part of the event payload.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
        public void Failure(string message) { WriteEvent(1, message); }

Applies to