EventLog
public static class EventLogClassContainer { public static string EvlLocation { get; set; } = ""; public static string EvlName { get; set; } = "Application"; public static string evlLocationManual = "%Test.evt%"; public static List<EventLogEntry> _LogEntries { get; private set; } public static void ReadEventLog() { EventLog evlLog = new EventLog(EvlName, "."); EventLogEntryCollection eventLogEntries = evlLog.Entries; int eventLogEntryCount = eventLogEntries.Count; foreach (EventLogEntry entry in evlLog.Entries) { //entry.Message _LogEntries = eventLogEntries.Cast<EventLogEntry>().ToList(); } } public static void SetEvlName(string evlLocation) { Parser.FileNameFinder(evlLocation, 3); } public static void RELSystemTest() { EventLog evlLog = new EventLog("Application", "."); EventLogEntryCollection eventLogEntries = evlLog.Entries; int eventLogEntryCount = eventLogEntries.Count; _LogEntries = eventLogEntries.Cast<EventLogEntry>().ToList(); } public static void ParseTest() { evlLocationManual = "K:\\Event Log\\Test\\Test.evt"; ReadEventLog(); } public static void setLogLocation(string input) { EvlLocation = input; } } public static class EventLogEntryCollection_Container { public static void testCollection() { string myLogName = "_log"; // Create an EventLog instance and assign its source. EventLog _log = new EventLog(); _log.Source = "%Program Files (x86)%\\EventLogParser\\ImportedEventLogs\\" + varBank.logInput; // Write an informational entry to the event log. _log.WriteEntry("Successfully created a new Entry in the Log"); _log.Close(); // Create a new EventLog object. EventLog myEventLog1 = new EventLog(); myEventLog1.Log = myLogName; // Obtain the Log Entries of "_log". EventLogEntryCollection _logCollection = _log.Entries; _log.Close(); // Copy the EventLog entries to Array of type EventLogEntry. EventLogEntry[] _logEntryArray = new EventLogEntry[_logCollection.Count]; _logCollection.CopyTo(_logEntryArray, 0); IEnumerator myEnumerator = _logEntryArray.GetEnumerator(); while (myEnumerator.MoveNext()) { EventLogEntry myEventLogEntry = (EventLogEntry)myEnumerator.Current; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)