DNSManagement.EventLogging.Count C# (CSharp) Method

Count() public method

Number of Entries in Event Log
public Count ( string logName ) : int
logName string
return int
        public int Count(string logName)
        {
            string query = String.Format("SELECT * FROM Win32_NTLogEvent Where LogFile='{0}'", logName);
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(m_scope, new ObjectQuery(query));

            ManagementObjectCollection collection = searcher.Get();
            return collection.Count;
        }

Usage Example

 public void EventLoggingCountSystemLog()
 {
     string host = Settings.Hostname;
     string username = Settings.Username;
     string password = Settings.Password;
     EventLogging target = new EventLogging(host, username, password);
     var system = target.Count(Settings.EventLogName);
     Assert.IsTrue(system > 0, "No Events in System log, check why");
 }
All Usage Examples Of DNSManagement.EventLogging::Count