EventAttribute.Level 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置事件的级别。
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