EventAttribute.Message プロパティ

定義

イベントのメッセージを取得または設定します。

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

プロパティ値

イベントに関するメッセージ。

次の例は、 プロパティを使用 Message してイベント メッセージを指定する方法を示しています。 このコード例は、EventSource クラスのために提供されている大規模な例の一部です。

[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
[Event(2, Message = "Starting up.", Keywords = Keywords.Perf, Level = EventLevel.Informational)]
public void Startup() { WriteEvent(2); }
<[Event](2, Message:="Starting up.", Keywords:=Keywords.Perf, Level:=EventLevel.Informational)> _
Public Sub Startup()
    WriteEvent(2)
End Sub
[Event(3, Message = "loading page {1} activityID={0}", Opcode = EventOpcode.Start,
    Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStart(int ID, string url) { if (IsEnabled()) WriteEvent(3, ID, url); }
<[Event](3, Message:="loading page {1} activityID={0}", Opcode:=EventOpcode.Start, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStart(ByVal ID As Integer, ByVal url As String)
    If IsEnabled() Then
        WriteEvent(3, ID, url)
    End If
End Sub

注釈

文字列では、標準の.NET Framework置換演算子 (例: {1}) を使用できます。 これらは、イベント ペイロードの対応する部分の文字列表現に置き換えられます。

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

適用対象