System.Diagnostics.EventLog evtLog = new System.Diagnostics.EventLog();
evtLog.Source = "application"; // 應用程式
evtLog.WriteEntry("message", System.Diagnostics.EventLogEntryType.Warning);
evtLog.WriteEntry("message", System.Diagnostics.EventLogEntryType.Warning, 12029);