日期:2018-12-18 浏览次数:160次

static void Main(string[] args)
{
    EventLog eventlog = new EventLog();
    eventlog.Log = "Security";
    //"Application"应用程序, "Security"安全, "System"系统
    EventLogEntryCollection eventLogEntryCollection = eventlog.Entries;
    foreach (EventLogEntry entry in eventLogEntryCollection)
    {
        //if (entry.EventID == 4624)
        //{
        //    continue;
        //}
        string info = string.Empty;
        if (@"TaskScheduler" == entry.Source.ToString())
        {
            info += "类型:" + entry.EntryType.ToString() + ";";
            info += "日期" + entry.TimeGenerated.ToLongDateString() + ";";
            info += "时间" + entry.TimeGenerated.ToLongTimeString() + ";";
            info += "来源" + entry.Source.ToString() + ";";
            Console.WriteLine(info);
        }
    }
}