System.Diagnostics 命名空間

提供類別,其允許與系統處理序、事件記錄檔和效能計數器互動。 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.

ActivityListener

允許接聽開始與停止活動事件,並提供讓您決定針對取樣案例建立活動的機會。Allows listening to the start and stop activity events and gives the opportunity to decide creating an activity for sampling scenarios.

ActivitySource

提供 API 來建立及啟動 Activity 物件,並註冊 ActivityListener 物件以接聽 Activity 事件。Provides APIs to create and start Activity objects and to register ActivityListener objects to listen to the Activity events.

ActivityTagsCollection

ActivityTagsCollection 是用來儲存追蹤標籤的一種集合類別。ActivityTagsCollection is a collection class used to store tracing tags.

此集合將搭配 ActivityEventActivityLink 等類別使用。This collection will be used with classes like ActivityEvent and ActivityLink.

此集合的運作方式如下:- 集合項目將會根據其加入方式排序。This collection behaves as follows: - The collection items will be ordered according to how they are added. - 不允許具有相同機碼的項目重複。- Don't allow duplication of items with the same key. - 使用索引子在集合中儲存項目時:- 如果項目具有先前存在於集合中的機碼,且值為 null,則會從集合中移除符合機碼的集合項目。- When using the indexer to store an item in the collection: - If the item has a key that previously existed in the collection and the value is null, the collection item matching the key will be removed from the collection. - 如果項目含有先前存在於集合中的機碼,且值不是 null,則新的項目值將會取代儲存在集合中的舊值。- If the item has a key that previously existed in the collection and the value is not null, the new item value will replace the old value stored in the collection. - 否則,項目將會加入集合。- Otherwise, the item will be added to the collection. - Add 方法會將新的項目加入集合 (如果還未存在具有相同機碼的項目)。- Add method will add a new item to the collection if an item doesn't already exist with the same key. 否則,其將會擲回例外狀況。Otherwise, it will throw an exception.

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 物件的強類型集合。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

修改執行階段 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 物件的強類型集合。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 物件的強類型集合。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.

StackTraceHiddenAttribute
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.

結構

ActivityContext

符合 W3C TraceContext 規格的表示法。A representation that conforms to the W3C TraceContext specification. 其包含兩個識別碼:TraceId 與 SpanId,以及一組常見的 TraceFlags 與系統特定 TraceState 值。It contains two identifiers: a TraceId and a SpanId, along with a set of common TraceFlags and system-specific TraceState values.

ActivityCreationOptions<T>

封裝傳送至活動接聽程式的所有資訊,以制定建立活動執行個體與其狀態的相關決策。Encapsulates all the information that is sent to the activity listener, to make decisions about the creation of the activity instance, as well as its state.

可能的泛型類型參數為 ActivityContextStringThe possible generic type parameters are ActivityContext or String.

ActivityEvent

代表包含名稱與時間戳記以及選用標籤清單的事件。Represents an event containing a name and a timestamp, as well as an optional list of tags.

ActivityLink

活動可能會連結至因果相關的零或多個活動內容執行個體。Activities may be linked to zero or more activity context instances that are causally related.

活動連結可以指向單一追蹤內或跨不同追蹤的活動內容。Activity links can point to activity contexts inside a single trace or across different traces.

活動連結可以用來代表批次作業,其中活動是由多個起始活動起始的,每個活動都代表批次中處理的單一傳入項目。Activity links can be used to represent batched operations where an activity was initiated by multiple initiating activities, each representing a single incoming item being processed in the batch.

ActivitySpanId

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

ActivityTagsCollection.Enumerator

列舉 ActivityTagsCollection 的項目。Enumerates the elements of an ActivityTagsCollection.

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.

ActivityKind

描述活動、其父代與追蹤中其子系之間的關聯性。Describes the relationship between the activity, its parents and its children in a trace.

ActivitySamplingResult

ActivityListener 所用的列舉值,其指出要針對相關 Activity 收集的資料量。 要求的資料越多,效能的負擔越大。Requesting more data causes a greater performance overhead.

ActivityStatusCode
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

指定直接對應到原生類型的效能計數器類型。Specifies performance counter types that map directly to native types.

PresentationTraceLevel

描述要追蹤有關特定物件的詳細資訊層級。Describes the level of detail to trace about a particular object.

ProcessPriorityClass

表示系統與處理序 (Process) 關聯的優先權。Indicates the priority that the system associates with a 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.

SampleActivity<T>

委派;可定義取樣程序中使用的 ActivityListener 回呼簽章。A delegate that defines the signature of the ActivityListener callbacks used in the sampling process.

備註

  • 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. 如需這些工作的詳細資訊,請參閱 EventLogPermissionEventLogEntryTypeEventLogEntryCollection 類別。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 ,並使用類別來計算連續效能計數器範例的結果 CounterSampleYou 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. 與效能計數器元件相關聯的其他類別可讓您存取計數器、counter 許可權和計數器類型的集合。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.