共用方式為


EventAttribute.Level 屬性

定義

取得或設定事件的層級。

public:
 property System::Diagnostics::Tracing::EventLevel Level { System::Diagnostics::Tracing::EventLevel get(); void set(System::Diagnostics::Tracing::EventLevel value); };
public System.Diagnostics.Tracing.EventLevel Level { get; set; }
member this.Level : System.Diagnostics.Tracing.EventLevel with get, set
Public Property Level As EventLevel

屬性值

其中一個列舉值,這個值指定事件的層級。

範例

下列範例示範如何使用 Level 屬性來指定事件層級。 此程式代碼範例是提供給 類別之較大範例的 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(7, Level = EventLevel.Verbose, Keywords = Keywords.DataBase)]
public void Mark(int ID) { if (IsEnabled()) WriteEvent(7, ID); }
<[Event](7, Level:=EventLevel.Verbose, Keywords:=Keywords.DataBase)> _
Public Sub Mark(ByVal ID As Integer)
    If IsEnabled() Then
        WriteEvent(7, ID)
    End If
End Sub

適用於