C#清理操作系统的日志,Clean Operating System’s Event Log

用C#实现清理操作系统的日志,是非常简单的事了,因为.net提供了一个EventLog类来封装这个完整的功能

using (EventLog el = new EventLog())
{
    el.Log = "Application";
    el.Clear();
}

默认情况下,服务器上存在三个日志文件: Application、System 和 Security。应用程序和服务使用 Application 日志文件。设备驱动程序使用 System 日志文件。打开审核时,系统在 Security 日志中生成成功审核事件和失败审核事件。如果安装了其他应用程序(如 Windows Server 上的 Active Directory),则可能会有其他默认日志文件。

Log 是日志的名称。可以是 Application、System 和 Security,或一个自定义的日志名称。