Example #1
0
        public static object[] GetEventLogDisplayObjects(string computerName, bool filterForTasks = true)
        {
            var ret = new List <ELObj>();

            try
            {
                using (EventLogSession session = GetEventLogSession(computerName))
                {
                    foreach (var s in session.GetLogNames())
                    {
                        try
                        {
                            var cfg = new EventLogConfiguration(s, session);
                            if (!filterForTasks || IsValidTaskLog(cfg))
                            {
                                ret.Add(new ELObj(session.GetLogDisplayName(s), s));
                            }
                        }
                        catch (Exception e) { System.Diagnostics.Debug.WriteLine($"Couldn't get display name for event log '{s}': {e.Message}"); }
                    }
                    ret.Sort();
                }
            }
            catch { }
            return(ret.ToArray());
        }