Before you can add events, you must register an event source by calling EventLog.CreateEventSource. You can then call EventLog.WriteEntry to add events. Read events by creating an instance of the EventLog class and accessing the EventLog.Entries collection. Use the Debug and Trace classes to log the internal workings of your application for troubleshooting purposes. Debug functions only in Debug releases. Trace can function with any release type. Users can configure listeners for Debug and Trace using the .config files.
To monitor performance counters programmatically, create an instance of PerformanceCounter. To add custom performance counters, call the static PerformanceCounterCategory.Create method. To provide performance counter data, create a PerformanceCounter object and set the ReadOnly property to false.
You can examine processes by calling the Process.GetProcesses method. To start a process, call Process.Start. To read WMI data, create a ManagementScope object and call ManagementScope.Connect. Then, create a query using an instance of ObjectQuery. You can also respond to WMI events by creating an instance of WqlEventQuery. Then use the WqlEventQuery to create an instance of ManagementEventWatcher. At this point, you can use ManagementEventWatcher to either create an event handler or wait for the next event.