EventLevel 列舉

定義

識別事件層級。Identifies the level of an event.

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

欄位

Critical 1

這個等級會對應至嚴重錯誤,也就是造成重大失敗的嚴重錯誤。This level corresponds to a critical error, which is a serious error that has caused a major failure.

Error 2

這個層級新增表示問題的標準錯誤。This level adds standard errors that signify a problem.

Informational 4

這個等級會加入非錯誤的告知性事件或訊息。This level adds informational events or messages that are not errors. 這些事件有助於追蹤應用程式的進度或狀態。These events can help trace the progress or state of an application.

LogAlways 0

未對事件進行任何層級篩選。No level filtering is done on the event.

Verbose 5

這個等級會加入冗長的事件或訊息。This level adds lengthy events or messages. 它會讓所有事件記錄下來。It causes all events to be logged.

Warning 3

這個等級會加入警告事件 (例如,磁碟容量快不夠時,所發行的事件)。This level adds warning events (for example, events that are published because a disk is nearing full capacity).

範例

下列範例顯示如何使用 Error 列舉成員來識別錯誤訊息。The following example shows how to use the Error enumeration member to identify an error message. 這個範例是針對類別提供之較大範例的一部分 EventSourceThis 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

下列範例顯示如何使用 Informational 列舉成員來識別參考用訊息。The following example shows how to use the Informational enumeration member to identify an informational message. 這個範例是針對類別提供之較大範例的一部分 EventSourceThis example is part of a larger example provided for the EventSource class.

[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 列舉成員來識別詳細訊息。The following example shows how to use the Verbose enumeration member to identify a verbose message. 這個範例是針對類別提供之較大範例的一部分 EventSourceThis example is part of a larger example provided for the EventSource class.

[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

備註

層級表示事件的嚴重性。The level signifies the severity of an event. 較低的嚴重性層級包含較高的嚴重性層級。Lower severity levels encompass higher severity levels. 例如, Warning 包含 ErrorCritical 層級(嚴重性較高)。For example, Warning includes the Error and Critical levels, which are higher in severity.

適用於