Home All Groups Group Topic Archive Search About

Recreating an event source in a new event log

Author
12 Apr 2006 11:01 AM
martin
Hi,

I recreating an event message source inside a new log but the messages keeps
ending up in the old log?! I have simplified my code into this tiny snippet:

    EventLog.CreateEventSource("mySrc", "myLog1");
    EventLog eventLog = new EventLog();
    eventLog.Source = "mySrc";
    eventLog.WriteEntry("MyEntry1");
    eventLog = null;

    if (EventLog.SourceExists("mySrc"))
    {
        EventLog.DeleteEventSource("mySrc");
        EventLog.CreateEventSource("mySrc", "myLog2");
    }
    eventLog = new EventLog();
    eventLog.Source = "mySrc";
    eventLog.WriteEntry("MyEntry2");
    eventLog = null;


The problem is that both "MyEntry1" and "MyEntry2" is written to "myLog1". I
had expected that "MyEntry2" would end up in "myLog2"? What's wrong with this
code?



regards,
martin

AddThis Social Bookmark Button