简体   繁体   中英

How do I clear all of the Event Logs in Windows?

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

using System.Diagnostics;

using(var eventLog = new EventLog("Security", System.Environment.MachineName);
    eventLog.Clear();

to delete the security events logs.

to delete all:

foreach (var eventLog in EventLog.GetEventLogs())
{         
     eventLog.Clear();
     eventLog.Dispose();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM