G
Guest
Hi,
I'm having some problems with the System.Diagnostics.EventLog class in .NET
2.0
I need to recreate 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?
sincerely,
martin
I'm having some problems with the System.Diagnostics.EventLog class in .NET
2.0
I need to recreate 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?
sincerely,
martin