This documentation is archived and is not being maintained.

System.Diagnostics Namespace

The System.Diagnostics namespace provides classes that allow you to interact with system processes, event logs, and performance counters.

  • 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. 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. For more information about these tasks, see the EventLogPermission, EventLogEntryType, and EventLogEntryCollection classes.
  • The Process class provides functionality to monitor system processes across the network, and to start and stop local system processes. In additional 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. 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.
  • 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). You can sample counters using the PerformanceCounter class, and calculate results from successive performance counter samples using the CounterSample class. 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.

The System.Diagnostics namespace also provides classes that allow you to debug your application and to trace the execution of your code. For more information, see the Trace and Debug classes.

Namespace hierarchy


Class Description
BooleanSwitch Provides a simple on/off switch that controls debugging and tracing output.
ConditionalAttribute Indicates to compilers that a method is callable if a specified preprocessing identifier is applied to the method.
CounterCreationData Defines the counter type, name, and Help string for a custom counter.
CounterCreationDataCollection Provides a strongly typed collection of CounterCreationData objects.
CounterSampleCalculator Provides a set of utility functions for interpreting performance counter data.
Debug Provides a set of methods and properties that help debug your code. This class cannot be inherited.
DebuggableAttribute 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.
DebuggerHiddenAttribute Specifies the DebuggerHiddenAttribute. This class cannot be inherited.
DebuggerStepThroughAttribute Specifies the DebuggerStepThroughAttribute. This class cannot be inherited.
DefaultTraceListener Provides the default output methods and behavior for tracing.
EntryWrittenEventArgs Provides data for the EntryWritten event.
EventLog Provides interaction with Windows event logs.
EventLogEntry Encapsulates a single record in the event log. This class cannot be inherited.
EventLogEntryCollection 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. This class is called by the installation utility, for example, InstallUtil.exe, when installing an event log.
EventLogPermission Allows control of code access permissions for event logging.
EventLogPermissionAttribute Allows declaritive permission checks for event logging.
EventLogPermissionEntry Defines the smallest unit of a code access security permission that is set for an EventLog.
EventLogPermissionEntryCollection Contains a strongly typed collection of EventLogPermissionEntry objects.
EventLogTraceListener Provides a simple listener that directs tracing or debugging output to an EventLog.
FileVersionInfo Provides version information for a physical file on disk.
InstanceData Holds instance data associated with a performance counter sample.
InstanceDataCollection Provides a strongly typed collection of InstanceData objects.
InstanceDataCollectionCollection Provides a strongly typed collection of InstanceDataCollection objects.
MonitoringDescriptionAttribute Specifies a description for a property or event.
PerformanceCounter Represents a Windows NT performance counter component.
PerformanceCounterCategory Represents a performance object, which defines a category of performance counters.
PerformanceCounterInstaller Specifies an installer for the PerformanceCounter component.
PerformanceCounterPermission Allows control of code access permissions for PerformanceCounter.
PerformanceCounterPermissionAttribute Allows declaritive performance counter permission checks.
PerformanceCounterPermissionEntry Defines the smallest unit of a code access security permission that is set for a PerformanceCounter.
PerformanceCounterPermissionEntryCollection Contains a strongly typed collection of PerformanceCounterPermissionEntry objects.
Process Provides access to local and remote processes and enables you to start and stop local system processes.
ProcessModule Represents a .dll or .exe file that is loaded into a particular process.
ProcessModuleCollection Provides a strongly typed collection of ProcessModule objects.
ProcessStartInfo Specifies a set of values used when starting a process.
ProcessThread Represents an operating system process thread.
ProcessThreadCollection Provides a strongly typed collection of ProcessThread objects.
StackFrame Provides information about a StackFrame, 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.
Switch Provides an abstract (MustInherit in Visual Basic) base class to create new debugging and tracing switches.
TextWriterTraceListener Directs tracing or debugging output to a TextWriter or to a Stream, such as Console.Out or FileStream.
Trace Provides a set of methods and properties that help you trace the execution of your code. This class cannot be inherited.
TraceListener Provides the abstract (MustInherit in Visual Basic) base class for the listeners who monitor trace and debug output.
TraceListenerCollection Provides a thread-safe list of TraceListener objects.
TraceSwitch Provides a multilevel switch to control tracing and debug output without recompiling your code.


Structure Description
CounterSample Defines a structure holding the raw data for a performance counter.


Delegate Description
EntryWrittenEventHandler Represents the method that will handle the EntryWritten event of an EventLog.


Enumeration Description
EventLogEntryType Specifies the event type of an event log entry.
EventLogPermissionAccess Defines access levels used by EventLog permission classes.
PerformanceCounterPermissionAccess Defines access levels used by PerformanceCounter permission classes.
PerformanceCounterType Specifies the formula used to calculate the NextValue method for a PerformanceCounter instance.
ProcessPriorityClass 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 Specified how a new window should appear when the system starts a process.
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.
TraceLevel Specifies what messages to output for the Debug, Trace and TraceSwitch classes.

See Also

.NET Framework Class Library