EventLogTraceListener.TraceEvent 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将事件跟踪信息写入事件日志。
重载
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, TraceEventCache, String, TraceEventType, Int32, String)
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
将跟踪信息、消息和事件信息写入事件日志。
public:
override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType severity, int id, System::String ^ message);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent(System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType severity, int id, string? message);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType severity, int id, string message);
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
Public Overrides Sub TraceEvent (eventCache As TraceEventCache, source As String, severity As TraceEventType, id As Integer, message As String)
参数
- eventCache
- TraceEventCache
包含当前进程 ID、线程 ID 和堆栈跟踪信息的对象。
- source
- String
用于标识输出的名称;通常生成跟踪事件的应用程序的名称。
- severity
- TraceEventType
枚举值之一,该值指定导致跟踪的事件的类型。
- id
- Int32
事件的数值标识符。 事件的组合 source 和 id 唯一标识。
- message
- String
跟踪消息。
- eventCache
- TraceEventCache
包含当前进程 ID、线程 ID 和堆栈跟踪信息的对象。
- source
- String
用于标识输出的名称;通常生成跟踪事件的应用程序的名称。
- severity
- TraceEventType
枚举值之一,该值指定导致跟踪的事件的类型。
- id
- Int32
事件的数值标识符。 事件的组合 source 和 id 唯一标识。
- message
- String
跟踪消息。
- 属性
例外
注解
Important
这些 TraceEvent 方法不应由应用程序代码调用。 这些方法由 的方法DebugTrace和TraceSource类调用以写入跟踪数据。
该方法 TraceEvent 旨在跟踪可由工具自动处理的事件。 例如,如果特定事件由特定源跟踪,监视工具可以通知管理员。
参数eventCachesource用于确定是否应跟踪事件。
id用于创建对象EventInstance,TraceEventType该对象等同于EventLogEntryType属性。EntryType 使用EventInstance该方法将数据写入事件日志messageWriteEvent。
注释
参数的 id 最大值为 65,535。
id如果指定的值大于 65,535,则使用最大值。
适用于
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[], TraceEventCache, String, TraceEventType, Int32, String, Object[])
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
- Source:
- EventLogTraceListener.cs
将跟踪信息、格式化的对象数组和事件信息写入事件日志。
public:
override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType severity, int id, System::String ^ format, ... cli::array <System::Object ^> ^ args);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent(System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType severity, int id, string? format, params object?[]? args);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType severity, int id, string format, params object[] args);
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
Public Overrides Sub TraceEvent (eventCache As TraceEventCache, source As String, severity As TraceEventType, id As Integer, format As String, ParamArray args As Object())
参数
- eventCache
- TraceEventCache
包含当前进程 ID、线程 ID 和堆栈跟踪信息的对象。
- source
- String
用于标识输出的名称;通常生成跟踪事件的应用程序的名称。
- severity
- TraceEventType
枚举值之一,该值指定导致跟踪的事件的类型。
- id
- Int32
事件的数值标识符。 事件的组合 source 和 id 唯一标识。
- format
- String
一个格式字符串,其中包含与数组中的 args 对象相对应的零个或多个格式项。
- args
- Object[]
包含 object 要设置格式的零个或多个对象的数组。
- eventCache
- TraceEventCache
包含当前进程 ID、线程 ID 和堆栈跟踪信息的对象。
- source
- String
用于标识输出的名称;通常生成跟踪事件的应用程序的名称。
- severity
- TraceEventType
枚举值之一,该值指定导致跟踪的事件的类型。
- id
- Int32
事件的数值标识符。 事件的组合 source 和 id 唯一标识。
- format
- String
一个格式字符串,其中包含与数组中的 args 对象相对应的零个或多个格式项。
- args
- Object[]
包含 object 要设置格式的零个或多个对象的数组。
- 属性
例外
注解
Important
这些 TraceEvent 方法不应由应用程序代码调用。 这些方法由 的方法DebugTrace和TraceSource类调用以写入跟踪数据。
该方法 TraceEvent 旨在跟踪可由工具自动处理的事件。 例如,如果特定事件由特定源跟踪,监视工具可以通知管理员。
参数eventCachesource用于确定是否应跟踪事件。
id用于创建对象EventInstance,TraceEventType该对象等同于EventLogEntryType属性。EntryType 使用EventInstance该方法将消息写入事件日志WriteEvent,并从参数format获取args消息。 使用 args 该方法将对象数组转换为字符串 Format ,传递 format 字符串和 args 数组以将字符串格式化为事件日志的消息。
注释
参数的 id 最大值为 65,535。
id如果指定的值大于 65,535,则使用最大值。