G
Guest
Hi,
My application write custom event log (i.e. NOT to the standard "system",
"application" or "Security" ones) using the EventLog class in .NET. The code
is essentially the same as those included in the MSDN library document for
EventLog.
using System;
using System.Diagnostics;
using System.Threading;
class MySample{
public static void Main(){
// Create the source, if it does not already exist.
if(!EventLog.SourceExists("MySource")){
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatingEventSource");
}
// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "MySource";
// Write an informational entry to the event log.
myLog.WriteEntry("Writing to event log.");
}
}
I found that these event logs I created using EventLog are ***different***
from those default event logs come with XP (again, those "System",
"Application" etc.)
For one, althogh I can see the event in EventViewer without problem, but
when I right click on my event log (for example, "MyNewLog", which is created
using the above sample), the properties for it is different from those for
the default system event log. The log name field is greyed out (empty) and
the Size, Created, Modified, and Accessed values are all empty (shown as "Not
avaiable".
The problem is that I tried to access my custom event log using the WMI.
With script such as this one:
Select * from Win32_NTEventlogFile
It only returns 3 objects, namely the default system event log ("system",
"application", and "security"). My custom event log file is NOT returned.
The static EventLog.GetEventLog (in .net) does returns me the correct
collections of event log files. But my application requires me to access
those files through WMI. I am stuck at here.
I have spend quit sometime trying to find out why. Any help will be
appreciated.
Thanks.
David
My application write custom event log (i.e. NOT to the standard "system",
"application" or "Security" ones) using the EventLog class in .NET. The code
is essentially the same as those included in the MSDN library document for
EventLog.
using System;
using System.Diagnostics;
using System.Threading;
class MySample{
public static void Main(){
// Create the source, if it does not already exist.
if(!EventLog.SourceExists("MySource")){
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatingEventSource");
}
// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "MySource";
// Write an informational entry to the event log.
myLog.WriteEntry("Writing to event log.");
}
}
I found that these event logs I created using EventLog are ***different***
from those default event logs come with XP (again, those "System",
"Application" etc.)
For one, althogh I can see the event in EventViewer without problem, but
when I right click on my event log (for example, "MyNewLog", which is created
using the above sample), the properties for it is different from those for
the default system event log. The log name field is greyed out (empty) and
the Size, Created, Modified, and Accessed values are all empty (shown as "Not
avaiable".
The problem is that I tried to access my custom event log using the WMI.
With script such as this one:
Select * from Win32_NTEventlogFile
It only returns 3 objects, namely the default system event log ("system",
"application", and "security"). My custom event log file is NOT returned.
The static EventLog.GetEventLog (in .net) does returns me the correct
collections of event log files. But my application requires me to access
those files through WMI. I am stuck at here.
I have spend quit sometime trying to find out why. Any help will be
appreciated.
Thanks.
David