如何清除Windows中的所有事件日志?

use*_*494 4 c# logging windows-services

如何使用C#清除Windows中的所有事件日志?

ess*_*kar 8

using System.Diagnostics;

using(var eventLog = new EventLog("Security", System.Environment.MachineName);
    eventLog.Clear();
Run Code Online (Sandbox Code Playgroud)

删除安全事件日志.

删除全部:

foreach (var eventLog in EventLog.GetEventLogs())
{         
     eventLog.Clear();
     eventLog.Dispose();
}
Run Code Online (Sandbox Code Playgroud)