Difference between System eventlog and those created by EventLog c




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

using System;
using System.Diagnostics;
using System.Threading;

class MySample{

public static void Main(){

// Create the source, if it does not already exist.
EventLog.CreateEventSource("MySource", "MyNewLog");

// 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

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




I was adviced by MS Platform SDK Team, that this is a known issue. The
fix will be available in Windows Server 2003 Service Pack 1. The fix
will allow you to access custom EventLogs that were created using .Net

Michael Freidgeim.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question