EventLevel 列舉

定義

識別事件層級。

public enum class EventLevel
public enum EventLevel
type EventLevel = 
Public Enum EventLevel
繼承
EventLevel

欄位

Critical 1

這個等級會對應至嚴重錯誤,也就是造成重大失敗的嚴重錯誤。

Error 2

這個層級新增表示問題的標準錯誤。

Informational 4

這個等級會加入非錯誤的告知性事件或訊息。 這些事件有助於追蹤應用程式的進度或狀態。

LogAlways 0

未對事件進行任何層級篩選。 當做啟用事件的層級篩選使用時,例如 EventListener.EnableEvents () 中,將會包含所有層級的事件。

Verbose 5

這個等級會加入冗長的事件或訊息。 它會讓所有事件記錄下來。

Warning 3

這個等級會加入警告事件 (例如,磁碟容量快不夠時,所發行的事件)。

範例

下列範例示範如何使用 Error 列舉成員來識別錯誤訊息。 此範例是針對 類別提供的較大範例的 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

下列範例示範如何使用 Informational 列舉成員來識別參考訊息。 此範例是針對 類別提供的較大範例的 EventSource 一部分。

[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

下列範例示範如何使用 Verbose 列舉成員來識別詳細資訊訊息。 此範例是針對 類別提供的較大範例的 EventSource 一部分。

[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

備註

層級表示事件的嚴重性。 較低嚴重性層級包含較高的嚴重性層級。 例如, Warning 包含 ErrorCritical 層級,這些層級在嚴重性中較高。

適用於