System.Diagnostics 命名空间

System.Diagnostics 命名空间提供类,使您能够与系统进程、事件日志和性能计数器进行交互。 The System.Diagnostics namespace provides classes that allow you to interact with system processes, event logs, and performance counters.

Activity

表示具有要用于日志记录的上下文的操作。Represents an operation with context to be used for logging.

BooleanSwitch

提供一个简单的 On/Off 开关,用于控制调试和跟踪输出。Provides a simple on/off switch that controls debugging and tracing output.

ConditionalAttribute

指示编译器,除非定义了指定的有条件编译符号,否则,应忽略方法调用或属性。Indicates to compilers that a method call or attribute should be ignored unless a specified conditional compilation symbol is defined.

ConsoleTraceListener

将跟踪或调试输出指引至标准输出或标准错误流。Directs tracing or debugging output to either the standard output or the standard error stream.

CorrelationManager

关联同属于某个逻辑事务的多个跟踪。Correlates traces that are part of a logical transaction.

CounterCreationData

定义自定义计数器的计数器类型、名称和帮助字符串。Defines the counter type, name, and Help string for a custom counter.

CounterCreationDataCollection

提供 CounterCreationData 对象的强类型集合。Provides a strongly typed collection of CounterCreationData objects.

CounterSampleCalculator

为解释性能计数器数据提供一组实用工具函数。Provides a set of utility functions for interpreting performance counter data.

DataReceivedEventArgs

提供有关 OutputDataReceivedErrorDataReceived 事件的数据。Provides data for the OutputDataReceived and ErrorDataReceived events.

Debug

提供一组有助于调试代码的方法和属性。Provides a set of methods and properties that help debug your code.

DebuggableAttribute

修改运行库实时 (JIT) 调试的代码生成。Modifies code generation for runtime just-in-time (JIT) debugging. 此类不能被继承。This class cannot be inherited.

Debugger

启用与调试器的通讯。Enables communication with a debugger. 此类不能被继承。This class cannot be inherited.

DebuggerBrowsableAttribute

确定是否在调试器变量窗口中显示成员以及如何显示成员。Determines if and how a member is displayed in the debugger variable windows. 此类不能被继承。This class cannot be inherited.

DebuggerDisplayAttribute

确定类或字段在调试器的变量窗口中的显示方式。Determines how a class or field is displayed in the debugger variable windows.

DebuggerHiddenAttribute

指定 DebuggerHiddenAttributeSpecifies the DebuggerHiddenAttribute. 此类不能被继承。This class cannot be inherited.

DebuggerNonUserCodeAttribute

标识不属于应用程序用户代码的类型或成员。Identifies a type or member that is not part of the user code for an application.

DebuggerStepperBoundaryAttribute

指示特性后面的代码将以运行模式而非单步执行模式执行。Indicates the code following the attribute is to be executed in run, not step, mode.

DebuggerStepThroughAttribute

指示调试器逐句通过代码,而不是进入并单步执行代码。Instructs the debugger to step through the code instead of stepping into the code. 此类不能被继承。This class cannot be inherited.

DebuggerTypeProxyAttribute

指定类型的显示代理。Specifies the display proxy for a type.

DebuggerVisualizerAttribute

指定类型具有可视化工具。Specifies that the type has a visualizer. 此类不能被继承。This class cannot be inherited.

DefaultTraceListener

提供用于跟踪的默认输出方法和行为。Provides the default output methods and behavior for tracing.

DelimitedListTraceListener

将跟踪或调试输出定向到文本编写器(如流编写器)或流(如文件流)。Directs tracing or debugging output to a text writer, such as a stream writer, or to a stream, such as a file stream.

DiagnosticListener

提供抽象 DiagnosticSource 类的实现,它表示源将其信息(事件)发送到的指定位置。Provides an implementation of the abstract DiagnosticSource class that represents a named place to which a source sends its information (events).

DiagnosticListenerExtensions
DiagnosticsConfigurationHandler

处理配置文件的诊断节。Handles the diagnostics section of configuration files.

DiagnosticSource

一个抽象类,它允许针对丰富数据有效负载的生产时日志记录检测代码,以在被检测的进程中使用。An abstract class that allows code to be instrumented for production-time logging of rich data payloads for consumption within the process that was instrumented.

EntryWrittenEventArgs

EntryWritten 事件提供数据。Provides data for the EntryWritten event.

EventInstance

表示事件日志项的非特定语言信息。Represents language-neutral information for an event log entry.

EventLog

提供与 Windows 事件日志的交互。Provides interaction with Windows event logs.

EventLogEntry

在事件日志中封装单个记录。Encapsulates a single record in the event log. 此类不能被继承。This class cannot be inherited.

EventLogEntryCollection

定义 EventLogEntry 实例集合的大小和枚举数。Defines size and enumerators for a collection of EventLogEntry instances.

EventLogInstaller

使您能够安装和配置应用程序在运行时所读取或写入的事件日志。Allows you to install and configure an event log that your application reads from or writes to when running.

EventLogPermission

控制事件日志的代码访问权限。Controls code access permissions for event logging.

EventLogPermissionAttribute

允许对事件日志进行声明性权限检查。Allows declarative permission checks for event logging.

EventLogPermissionEntry

定义为 EventLog 设置的代码访问安全性权限的最小单位。Defines the smallest unit of a code access security permission that is set for an EventLog.

EventLogPermissionEntryCollection

包含 EventLogPermissionEntry 对象的强类型集合。Contains a strongly typed collection of EventLogPermissionEntry objects.

EventLogTraceListener

提供一个简单的侦听器,该侦听器将跟踪或调试输出指引至 EventLogProvides a simple listener that directs tracing or debugging output to an EventLog.

EventSchemaTraceListener

将端对端事件的跟踪或调试输出定向到 XML 编码的符合架构的日志文件。Directs tracing or debugging output of end-to-end events to an XML-encoded, schema-compliant log file.

EventSourceCreationData

表示用于在本地或远程计算机上创建事件日志源的配置设置。Represents the configuration settings used to create an event log source on the local computer or a remote computer.

EventTypeFilter

指示侦听器是否应该基于事件类型进行跟踪。Indicates whether a listener should trace based on the event type.

FileVersionInfo

为磁盘上的物理文件提供版本信息。Provides version information for a physical file on disk.

InstanceData

保存与性能计数器样本关联的实例数据。Holds instance data associated with a performance counter sample.

InstanceDataCollection

提供 InstanceData 对象的强类型集合。Provides a strongly typed collection of InstanceData objects.

InstanceDataCollectionCollection

提供 InstanceDataCollection 对象的强类型集合。Provides a strongly typed collection of InstanceDataCollection objects.

MonitoringDescriptionAttribute

指定属性或事件的说明。Specifies a description for a property or event.

PerformanceCounter

表示 Windows NT 性能计数器组件。Represents a Windows NT performance counter component.

PerformanceCounterCategory

表示性能对象,它定义性能计数器的类别。Represents a performance object, which defines a category of performance counters.

PerformanceCounterInstaller

指定 PerformanceCounter 组件的安装程序。Specifies an installer for the PerformanceCounter component.

PerformanceCounterManager

为系统使用性能计数器时加载的 performance.dll 准备性能数据。Prepares performance data for the performance.dll the system loads when working with performance counters.

PerformanceCounterPermission

允许控制 PerformanceCounter 的代码访问权限。Allows control of code access permissions for PerformanceCounter.

PerformanceCounterPermissionAttribute

允许声明性性能计数器权限检查。Allows declarative performance counter permission checks.

PerformanceCounterPermissionEntry

定义为 PerformanceCounter 设置的代码访问安全性权限的最小单位。Defines the smallest unit of a code access security permission that is set for a PerformanceCounter.

PerformanceCounterPermissionEntryCollection

包含 PerformanceCounterPermissionEntry 对象的强类型集合。Contains a strongly typed collection of PerformanceCounterPermissionEntry objects.

PresentationTraceSources

提供专门针对 Windows Presentation Foundation (WPF) 应用程序的调试跟踪支持。Provides debug tracing support that is specifically targeted for Windows Presentation Foundation (WPF) applications.

Process

提供对本地和远程进程的访问权限并使你能够启动和停止本地系统进程。Provides access to local and remote processes and enables you to start and stop local system processes.

ProcessModule

表示加载到特定进程的 .dll 或 .exe 文件。Represents a.dll or .exe file that is loaded into a particular process.

ProcessModuleCollection

提供 ProcessModule 对象的强类型集合。Provides a strongly typed collection of ProcessModule objects.

ProcessStartInfo

指定启动进程时使用的一组值。Specifies a set of values that are used when you start a process.

ProcessThread

表示操作系统进程线程。Represents an operating system process thread.

ProcessThreadCollection

提供 ProcessThread 对象的强类型集合。Provides a strongly typed collection of ProcessThread objects.

SourceFilter

指示侦听器是否应基于跟踪源跟踪消息。Indicates whether a listener should trace a message based on the source of a trace.

SourceSwitch

提供多级开关,用于控制跟踪和调试输出,而无需重新编译代码。Provides a multilevel switch to control tracing and debug output without recompiling your code.

StackFrame

提供关于 StackFrame(表示当前线程的调用堆栈中的一个函数调用)的信息。Provides information about a StackFrame, which represents a function call on the call stack for the current thread.

StackFrameExtensions

提供用于 StackFrame 类(表示当前线程的调用堆栈中的一个函数调用)的扩展方法。Provides extension methods for the StackFrame class, which represents a function call on the call stack for the current thread.

StackTrace

表示一个堆栈跟踪,它是一个或多个堆栈帧的有序集合。Represents a stack trace, which is an ordered collection of one or more stack frames.

Stopwatch

提供一组方法和属性,可用于准确地测量运行时间。Provides a set of methods and properties that you can use to accurately measure elapsed time.

Switch

提供一个用于创建新的调试和跟踪开关的抽象基类。Provides an abstract base class to create new debugging and tracing switches.

SwitchAttribute

标识程序集、类或成员中使用的开关。Identifies a switch used in an assembly, class, or member.

SwitchLevelAttribute

标识开关的级别类型。Identifies the level type for a switch.

TextWriterTraceListener

将跟踪或调试输出定向到 TextWriterStream,如 FileStreamDirects tracing or debugging output to a TextWriter or to a Stream, such as FileStream.

Trace

提供一组方法和属性,帮助您跟踪代码的执行。Provides a set of methods and properties that help you trace the execution of your code. 此类不能被继承。This class cannot be inherited.

TraceEventCache

提供特定于线程和进程的跟踪事件数据。Provides trace event data specific to a thread and a process.

TraceFilter

为跟踪筛选器实现提供基类。Provides the base class for trace filter implementations.

TraceListener

为监视跟踪和调试输出的侦听器提供 abstract 基类。Provides the abstract base class for the listeners who monitor trace and debug output.

TraceListenerCollection

提供 TraceListener 对象的线程安全列表。Provides a thread-safe list of TraceListener objects.

TraceSource

提供一组方法和属性,利用这些方法和属性,应用程序可以跟踪代码的执行并将跟踪消息和它们的源关联起来。Provides a set of methods and properties that enable applications to trace the execution of code and associate trace messages with their source.

TraceSwitch

提供多级开关,用于控制跟踪和调试输出,而无需重新编译代码。Provides a multilevel switch to control tracing and debug output without recompiling your code.

UnescapedXmlDiagnosticData

提供非转义 XML 数据以记录用户提供的跟踪数据。Provides unescaped XML data for the logging of user-provided trace data.

XmlWriterTraceListener

将跟踪或调试输出作为 XML 编码的数据定向到 TextWriterStream(如 FileStream)。Directs tracing or debugging output as XML-encoded data to a TextWriter or to a Stream, such as a FileStream.

结构

ActivitySpanId

表示 SpanId,其格式基于 W3C 标准。Represents a SpanId formatted based on a W3C standard.

ActivityTraceId

表示 TraceId,其格式基于 W3C 标准。Represents a TraceId whose format is based on a W3C standard.

CounterSample

定义存放性能计数器的原始数据的结构。Defines a structure that holds the raw data for a performance counter.

接口

ICollectData

为系统使用性能计数器时加载的性能 DLL 准备性能数据。Prepares performance data for the performance DLL the system loads when working with performance counters.

枚举

ActivityIdFormat

指定 Id 属性的格式。Specifies the format of the Id property.

ActivityTraceFlags

指定由 W3C 标准定义的与活动关联的标志。Specifies flags defined by the W3C standard that are associated with an activity.

DebuggableAttribute.DebuggingModes

指定实时 (JIT) 编译器的调试模式。Specifies the debugging mode for the just-in-time (JIT) compiler.

DebuggerBrowsableState

指定调试器的显示方式。Provides display instructions for the debugger.

EventLogEntryType

指定事件日志项的事件类型。Specifies the event type of an event log entry.

EventLogPermissionAccess

定义 EventLog 权限类使用的访问级别。Defines access levels used by EventLog permission classes.

OverflowAction

指定如何处理已达到最大文件大小的事件日志中的项。Specifies how to handle entries in an event log that has reached its maximum file size.

PerformanceCounterCategoryType

指示性能计数器类别是否可以有多个实例。Indicates whether the performance counter category can have multiple instances.

PerformanceCounterInstanceLifetime

指定性能计数器实例的生存期。Specifies the lifetime of a performance counter instance.

PerformanceCounterPermissionAccess

定义 PerformanceCounter 权限类使用的访问级别。Defines access levels used by PerformanceCounter permission classes.

PerformanceCounterType

NextValue() 实例指定用于计算 PerformanceCounter 方法的公式。Specifies the formula used to calculate the NextValue() method for a PerformanceCounter instance.

PresentationTraceLevel

说明对特定对象进行跟踪的详细等级。Describes the level of detail to trace about a particular object.

ProcessPriorityClass

指示系统将与进程关联的优先级。 此值与进程的每个线程的优先级值一起来确定每个线程的基本优先级别。This value, together with the priority value of each thread of the process, determines each thread's base priority level.

ProcessWindowStyle

指定在系统启动进程时新窗口应如何显示。Specified how a new window should appear when the system starts a process.

SourceLevels

指定由源开关和事件类型筛选器筛选的跟踪消息的级别。Specifies the levels of trace messages filtered by the source switch and event type filter.

ThreadPriorityLevel

指定线程的优先级别。Specifies the priority level of a thread.

ThreadState

指定线程的当前执行状态。Specifies the current execution state of the thread.

ThreadWaitReason

指定线程等待的原因。Specifies the reason a thread is waiting.

TraceEventType

标识引起跟踪的事件的类型。Identifies the type of event that has caused the trace.

TraceLevel

指定为 DebugTraceTraceSwitch 类输出的消息。Specifies what messages to output for the Debug, Trace and TraceSwitch classes.

TraceLogRetentionOption

指定将用于 EventSchemaTraceListener 日志的文件结构。Specifies the file structure that will be used for the EventSchemaTraceListener log.

TraceOptions

指定要写入跟踪输出中的跟踪数据选项。Specifies trace data options to be written to the trace output.

委托

DataReceivedEventHandler

表示将处理 OutputDataReceivedErrorDataReceived 事件或 Process 事件的方法。Represents the method that will handle the OutputDataReceived event or ErrorDataReceived event of a Process.

EntryWrittenEventHandler

表示将要处理 EventLogEntryWritten 事件的方法。Represents the method that will handle the EntryWritten event of an EventLog.

注解

  • EventLog组件提供了功能来向事件日志中写入、 读取事件日志项,并创建和删除事件日志和网络上的事件源。The EventLog component provides functionality to write to event logs, read event log entries, and create and delete event logs and event sources on the network. EntryWrittenEventHandler使您能够以异步方式与事件日志进行交互。The EntryWrittenEventHandler provides a way to interact with event logs asynchronously. 支持类提供对更细致的控制访问权限包括: 权限限制,以及若要指定事件日志类型 (控件的事件日志条目写入的默认数据类型),并循环访问集合的事件日志的功能条目。Supporting classes provide access to more detailed control, including: permission restrictions, the ability to specify event log types (which controls the type of default data that is written with an event log entry), and iterate through collections of event log entries. 有关这些任务的详细信息,请参阅EventLogPermissionEventLogEntryType,和EventLogEntryCollection类。For more information about these tasks, see the EventLogPermission, EventLogEntryType, and EventLogEntryCollection classes.

  • Process类提供跨网络监视系统进程还可以启动和停止本地系统进程的功能。The Process class provides functionality to monitor system processes across the network, and to start and stop local system processes. 除了检索正在运行的进程 (通过指定计算机、 进程名称或进程 id) 或查看有关当前有权访问处理器过程的信息的列表,可以获得的进程线程的详细的知识和模块这两个通过Process本身,并通过与之交互ProcessThreadProcessModule类。In addition to retrieving lists of running processes (by specifying either the computer, the process name, or the process id) or viewing information about the process that currently has access to the processor, you can get detailed knowledge of process threads and modules both through the Process class itself, and by interacting with the ProcessThread and ProcessModule classes. ProcessStartInfo类,可指定各种用来启动一个新进程,例如输入、 输出和错误流、 工作目录、 命令行谓词和自变量的元素。The ProcessStartInfo class enables you to specify a variety of elements with which to start a new process, such as input, output, and error streams, working directories, and command line verbs and arguments. 这些报告提供对您的流程的行为进行精细控制。These give you fine control over the behavior of your processes. 其他相关的类使你可以指定窗口样式、 进程和线程优先级,以及与集合的线程和模块进行交互。Other related classes let you specify window styles, process and thread priorities, and interact with collections of threads and modules.

  • PerformanceCounter类可用于监视系统性能,而PerformanceCounterCategory类提供了一种方法来创建新的自定义计数器和类别。The PerformanceCounter class enables you to monitor system performance, while the PerformanceCounterCategory class provides a way to create new custom counters and categories. 可以将写入到本地的自定义计数器,并从本地和远程计数器 (系统,以及自定义) 中读取。You can write to local custom counters and read from both local and remote counters (system as well as custom). 可以使用的计数器进行采样PerformanceCounter类,并计算中使用连续的性能计数器样本的结果CounterSample类。You can sample counters using the PerformanceCounter class, and calculate results from successive performance counter samples using the CounterSample class. CounterCreationData类,可创建多个计数器类别中,并指定其类型。The CounterCreationData class enables you to create multiple counters in a category and specify their types. 与性能计数器组件关联的其他类提供对计数器,计数器权限和计数器类型的集合的访问。Other classes associated with the performance counter component provide access to collections of counters, counter permission, and counter types.

System.Diagnostics命名空间还提供类,使您能够调试应用程序,并跟踪你的代码的执行。The System.Diagnostics namespace also provides classes that allow you to debug your application and to trace the execution of your code. 有关更多信息,请参见 TraceDebug 类。For more information, see the Trace and Debug classes.