TraceListener.TraceEvent 方法

定义

向特定于侦听器的输出写入跟踪和事件信息。

重载

TraceEvent(TraceEventCache, String, TraceEventType, Int32)

向特定于侦听器的输出写入跟踪和事件信息。

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

向特定于侦听器的输出中写入跟踪信息、消息和事件信息。

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])

向特定于侦听器的输出中写入跟踪信息、格式化对象数组和事件信息。

TraceEvent(TraceEventCache, String, TraceEventType, Int32)

Source:
TraceListener.cs
Source:
TraceListener.cs
Source:
TraceListener.cs

向特定于侦听器的输出写入跟踪和事件信息。

C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id);
C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id);

参数

eventCache
TraceEventCache

包含当前进程 ID、线程 ID 以及堆栈跟踪信息的 TraceEventCache 对象。

source
String

标识输出时使用的名称,通常为生成跟踪事件的应用程序的名称。

eventType
TraceEventType

TraceEventType 值之一,指定引发跟踪的事件类型。

id
Int32

事件的数值标识符。

属性

注解

重要

此方法不是由应用程序代码直接调用,而是由 、 TraceTraceSource 类的成员Debug调用,以将跟踪数据写入输出。

默认实现将 和 eventTypeid 参数的值source写入标头。 数据 eventCache 以页脚形式写入,输出数据的性质取决于 属性的值 TraceOutputOptions

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

Source:
TraceListener.cs
Source:
TraceListener.cs
Source:
TraceListener.cs

向特定于侦听器的输出中写入跟踪信息、消息和事件信息。

C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string? message);
C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string message);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string message);

参数

eventCache
TraceEventCache

包含当前进程 ID、线程 ID 以及堆栈跟踪信息的 TraceEventCache 对象。

source
String

标识输出时使用的名称,通常为生成跟踪事件的应用程序的名称。

eventType
TraceEventType

TraceEventType 值之一,指定引发跟踪的事件类型。

id
Int32

事件的数值标识符。

message
String

要写入的消息。

属性

注解

重要

此方法不是由应用程序代码直接调用,而是由 、 TraceTraceSource 类的成员Debug调用,以将跟踪数据写入输出。

默认实现将 和 eventTypeid 参数的值source写入为标头,后跟message数据。 数据 eventCache 以页脚形式写入,输出数据的性质取决于 属性的值 TraceOutputOptions

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])

Source:
TraceListener.cs
Source:
TraceListener.cs
Source:
TraceListener.cs

向特定于侦听器的输出中写入跟踪信息、格式化对象数组和事件信息。

C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object?[]? args);
C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string? format, params object?[]? args);
C#
public virtual void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object[] args);
C#
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object[] args);

参数

eventCache
TraceEventCache

包含当前进程 ID、线程 ID 以及堆栈跟踪信息的 TraceEventCache 对象。

source
String

标识输出时使用的名称,通常为生成跟踪事件的应用程序的名称。

eventType
TraceEventType

TraceEventType 值之一,指定引发跟踪的事件类型。

id
Int32

事件的数值标识符。

format
String

一个格式字符串,其中包含零个或多个格式项,它们对应于 args 数组中的对象。

args
Object[]

包含零个或多个要格式化的对象的 object 数组。

属性

注解

重要

此方法不是由应用程序代码直接调用,而是由 、 TraceTraceSource 类的成员Debug调用,以将跟踪数据写入输出。

默认实现将 和 eventTypeid 参数的值source写入标头。 对象 args 数组使用 Format 方法转换为字符串,传递 format 字符串和 args 数组以将字符串格式化为跟踪的消息部分。 数据 eventCache 以页脚形式写入,输出数据的性质取决于 属性的值 TraceOutputOptions

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1