|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to access custom event logs via WMI Win32_NTEventlogFilerunning .NET 1.1 in C#. I am using the following to do that: using System; using System.Management; namespace WMIEventLogTest { class Class1 { [STAThread] static void Main(string[] args) { ManagementClass mc = new ManagementClass("Win32_NTEventlogFile"); ManagementObjectCollection moc = mc.GetInstances(); Console.WriteLine( "List event log name using ManagmentObjectCollection:"); foreach (ManagementObject mo in moc) { Console.WriteLine( mo["LogfileName"].ToString()); } Console.WriteLine( "--------------"); Console.WriteLine( "List event log names using MangementObjectSearcher:"); SelectQuery query = new SelectQuery( "SELECT * FROM Win32_NTEventlogFile"); ManagementObjectSearcher searcher = new ManagementObjectSearcher( query); foreach (ManagementObject mo in searcher.Get()) { Console.WriteLine( mo["LogfileName"].ToString()); } } } } The output is: List event log name using ManagmentObjectCollection: Application Security System -------------- List event log names using MangementObjectSearcher: Application Security System I have some custom event logs configured on the system but this program does not list them. I am running the program as Administrator. I am looking for suggestions on how to access these log files through WMI. What do you think? Thank you! |
|||||||||||||||||||||||