指通過windows自帶的 管理工具》事件查看器 查看的應用程序日誌。
可通過C# 類 System.Diagnostics.EventLog 的 static 方法 WriteEntry 方便的寫入日誌。
//
// 摘要:
// 通過指定的註冊事件源,將一個包含給定消息文本、應用程序定義的事件標識符和應用程序定義的類別的項寫入事件日誌。 事件查看器可使用 category
// 篩選日誌中的事件。
//
// 參數:
// source:
// 應用程序在指定計算機上用來註冊的源。
//
// message:
// 要寫入事件日誌的字符串。
//
// type:
// System.Diagnostics.EventLogEntryType 值之一。
//
// eventID:
// 事件的應用程序特定標識符。
//
// category:
// 與消息關聯的應用程序特定子類別。
//
// 異常:
// System.ArgumentException:
// source 值是空字符串 ("")。 - 或 - source 值爲 null。 - 或 - eventID 小於零或大於 System.UInt16.MaxValue。
// - 或 - 該消息字符串的長度超過了 32766 個字節。 - 或 - 此源名稱導致註冊表項路徑的長度超過 254 個字符。
//
// System.InvalidOperationException:
// 事件日誌的註冊表項未能打開。
//
// System.ComponentModel.InvalidEnumArgumentException:
// type 不是有效的 System.Diagnostics.EventLogEntryType。
//
// System.ComponentModel.Win32Exception:
// 將事件項寫入事件日誌時,操作系統報告了一個錯誤。 一個 Windows 錯誤代碼不可用。
public static void WriteEntry(string source, string message, EventLogEntryType type, int eventID, short category);