EventWrittenEventArgs 类

定义

OnEventWritten(EventWrittenEventArgs) 回调提供数据。Provides data for the OnEventWritten(EventWrittenEventArgs) callback.

public ref class EventWrittenEventArgs : EventArgs
public class EventWrittenEventArgs : EventArgs
type EventWrittenEventArgs = class
    inherit EventArgs
Public Class EventWrittenEventArgs
Inherits EventArgs
继承
EventWrittenEventArgs

注解

每当事件调度到EventListener,则EventListener.OnEventWritten调用回调方法。Whenever an event is dispatched to an EventListener, the EventListener.OnEventWritten callback method is invoked. 它传递EventWrittenEventArgs实例,它包含与事件相关联的信息。It is passed an EventWrittenEventArgs instance that contains information associated with the event. 所有属性值的EventWrittenEventArgs类仅在回调过程都有效。All property values of the EventWrittenEventArgs class are valid only during the callback.

以下各节包含有关个人的其他信息EventWrittenEventArgs属性。The following sections contain additional information about individual EventWrittenEventArgs properties.

ActivityId 属性ActivityId property

当使用System.Activities.Activity和及其派生的类,线程可以标记为具有与之关联的活动。When using System.Activities.Activity and its derived classes, threads can be marked as having an activity associated with them. ActivityId属性返回的记录事件的线程的活动 ID。The ActivityId property returns the activity ID of the thread that logged the event. 注意,线程不需要具有一项活动,在这种情况下此属性返回Guid.EmptyNote that threads do not have to have an activity, in which case this property returns Guid.Empty.

OSThreadId 和时间戳属性OSThreadId and TimeStamp properties

从.NET Core 2.2 开始EventListener对象可以订阅本机运行时事件 (例如 GC、 JIT 和线程池事件) 发出的事件除了EventSource对象。Starting with .NET Core 2.2, EventListener objects can subscribe to native runtime events (such as GC, JIT, and threadpool events) in addition to events emitted by EventSource objects. 在早期版本的 .NET Core 和所有版本的 .NET Framework 中, 可以从环境中收集线程 ID 和时间戳, 因为这些 ID 和时间戳是在发出它们的同一线程上同步调度的。In previous versions of .NET Core and all versions of .NET Framework, the thread ID and timestamp can be gathered from the environment, because they are dispatched synchronously on the same thread that emitted them. 并非所有的本机运行时事件,就无法调度同步,但是。Not all native runtime events can be dispatched synchronously, however. 托管时发出一些事件,如 GC 事件挂起线程执行。Some events, such as GC events, are emitted when managed thread execution is suspended. 这些事件在本机代码中进行缓冲和调度由调度程序线程可以再次执行托管的代码后。These events are buffered in native code and are dispatched by a dispatcher thread once managed code can execute again. 因为这些事件进行缓冲,环境不能用于可靠地检索的线程 ID 和时间戳。Because these events are buffered, the environment cannot be used to reliably retrieve the thread ID and timestamp. 因此,从.NET Core 2.2 开始线程 ID 和时间戳信息都可用作成员EventWrittenEventArgs类。Because of this, starting with .NET Core 2.2, thread ID and timestamp information are available as members of the EventWrittenEventArgs class.

RelatedActivityId 属性RelatedActivityId property

相关的活动是与当前紧密相关的活动。A related activity is an activity that is strongly related to the current one. 通常情况下,它是导致当前活动的这两种活动 (具有事件Start操作码通常执行此操作) 或已通过当前的活动 (具有事件Send操作码通常执行此操作)。Typically, it is either the activity that caused the current activity (events with the Start opcode typically do this) or an activity that was created by the current one (events with the Send opcode typically do this). 使用它时,RelatedActivityID显式传递由执行日志记录的方法。When it is used, the RelatedActivityID is explicitly passed by the method doing the logging. 许多事件都不传递RelatedActivityId,在这种情况下此属性返回Guid.EmptyMany events don't pass a RelatedActivityId, in which case this property returns Guid.Empty.

属性

ActivityId

获取向其写入了事件的线程上的活动 ID。Gets the activity ID on the thread that the event was written to.

Channel

获取事件的通道。Gets the channel for the event.

EventId

获取事件标识符。Gets the event identifier.

EventName

获取事件的名称。Gets the name of the event.

EventSource

获取事件源对象。Gets the event source object.

Keywords

获取事件的关键字。Gets the keywords for the event.

Level

获取事件的级别。Gets the level of the event.

Message

获取事件的消息。Gets the message for the event.

Opcode

获取事件的操作代码。Gets the operation code for the event.

OSThreadId

获取编写此事件的 OS 线程的线程标识符。Gets the thread identifier for the OS thread that wrote the event. (仅 .NET Core 2.2 和更高版本。)(.NET Core 2.2 and later only.)

Payload

获取事件的负载。Gets the payload for the event.

PayloadNames

返回表示事件的属性名称的字符串的列表。Returns a list of strings that represent the property names of the event.

RelatedActivityId

获取与当前实例表示的活动相关的活动的标识符。Gets the identifier of an activity that is related to the activity represented by the current instance.

Tags

返回在 Write(String, EventSourceOptions) 方法调用中指定的标记。Returns the tags specified in the call to the Write(String, EventSourceOptions) method.

Task

获取事件的任务。Gets the task for the event.

TimeStamp

获取事件作为 DateTime 时间戳最初生成的时间。Gets the time that the event was originally generated as a DateTime timestamp. (仅 .NET Core 2.2 和更高版本。)(.NET Core 2.2 and later only.)

Version

获取事件的版本。Gets the version of the event.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于