Esempio n. 1
0
        public static EventLogProperties GetEventLogProperties(string machineName, string eventLogName)
        {
            EventLogProperties elp = new EventLogProperties()
            {
                MachineName = machineName, Name = eventLogName
            };

            try
            {
                using (RegistryKey remoteLMKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machineName))
                {
                    using (RegistryKey eventlogKey = remoteLMKey.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\Eventlog\\" + eventLogName, false))
                    {
                        elp.MaxSize            = System.Convert.ToInt64(eventlogKey.GetValue("MaxSize", 524288));
                        elp.Retention          = System.Convert.ToInt64(eventlogKey.GetValue("Retention", 0));
                        elp.AutoBackupLogFiles = System.Convert.ToInt64(eventlogKey.GetValue("AutoBackupLogFiles", 0));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error retrieving event log propeties for {0}", eventLogName), ex);
            }
            return(elp);
        }
Esempio n. 2
0
 public static void SetEventLogProperties(EventLogProperties elp)
 {
     SetEventLogProperties(elp.MachineName, elp.Name, elp.MaxSize, elp.Retention, elp.AutoBackupLogFiles);
 }