System.Diagnostics 命名空間

System.Diagnostics 命名空間提供類別,允許您與系統處理序 (Process)、事件記錄檔和效能計數器互動。 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

提供簡單的開啟/關閉切換,控制偵錯與追踨的輸出。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 物件的強型別 (Strongly Typed) 集合。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

修改 Runtime Just-In-Time (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

指定類型的顯示 Proxy。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

定義程式碼存取安全性權限的最小單位,是設定給 EventLogDefines 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

保存與效能計數器樣本相關的執行個體 (Instance) 資料。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 物件的強型別 (Strongly Typed) 集合。Provides a strongly typed collection of ProcessModule objects.

ProcessStartInfo

指定一組啟動處理序時所使用的值。Specifies a set of values that are used when you start a process.

ProcessThread

表示作業系統處理序 (Process) 執行緒。Represents an operating system process thread.

ProcessThreadCollection

提供 ProcessThread 物件的強型別 (Strongly Typed) 集合。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,例如做為 FileStreamDirects tracing or debugging output as XML-encoded data to a TextWriter or to a Stream, such as a FileStream.

結構

ActivitySpanId

代表以 W3C 標準作為格式基礎的 SpanIdRepresents a SpanId formatted based on a W3C standard.

ActivityTraceId

代表以 W3C 標準作為格式基礎的 TraceIdRepresents a TraceId whose format is based on a W3C standard.

CounterSample

定義為效能計數器保留未經處理資料 (Raw Data) 的結構。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

指定 Just-In-Time (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() 執行個體 (Instance) 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

表示系統與處理序 (Process) 關聯的優先權。 這個值與處理序每個執行緒的優先權值會判斷每個執行緒的基礎優先權層級。This value, together with the priority value of each thread of the process, determines each thread's base priority level.

ProcessWindowStyle

指定系統啟動處理序 (Process) 時新視窗出現的方式。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. 除了擷取執行中處理序 (藉由指定電腦、 處理序名稱或處理序識別碼),或檢視目前的處理器的存取權的程序的相關資訊的清單,您可以取得處理序執行緒的詳細的知識,透過模組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.