Event Log Madness - Changing the log associated with a log
-
Hi, I have created an entry in a custom event log:
if (!EventLog.SourceExists("TestSource"))
EventLog.CreateEventSource("TestSource", "System");
EventLog evtLog = new EventLog();
evtLog.Source = "TestSource";
evtLog.WriteEntry("This is a test", EventLogEntryType.Information);I now decide to use my own custom log so I change "System" to "TestLog". This doesn't do anything. The event is still logged to the "System" log even if I try deleting the source but if I use a different source, it then gets logged correctly to "TestLog"
if (EventLog.SourceExists("TestSource"))
EventLog.DeleteEventSource("TestSource");If I go into the registry, I find a list of sources for the System event log but even if I delete the TestSource entry from there it still logs events to the System event log. This MSDN article suggests that you can remove a source association from a log but it's not correct as far as I can tell: http://msdn.microsoft.com/en-us/library/k57466fc(VS.71).aspx[^] What's going on? It seems that once a source is associated with a log there's no way of removing that association.
-
Hi, I have created an entry in a custom event log:
if (!EventLog.SourceExists("TestSource"))
EventLog.CreateEventSource("TestSource", "System");
EventLog evtLog = new EventLog();
evtLog.Source = "TestSource";
evtLog.WriteEntry("This is a test", EventLogEntryType.Information);I now decide to use my own custom log so I change "System" to "TestLog". This doesn't do anything. The event is still logged to the "System" log even if I try deleting the source but if I use a different source, it then gets logged correctly to "TestLog"
if (EventLog.SourceExists("TestSource"))
EventLog.DeleteEventSource("TestSource");If I go into the registry, I find a list of sources for the System event log but even if I delete the TestSource entry from there it still logs events to the System event log. This MSDN article suggests that you can remove a source association from a log but it's not correct as far as I can tell: http://msdn.microsoft.com/en-us/library/k57466fc(VS.71).aspx[^] What's going on? It seems that once a source is associated with a log there's no way of removing that association.
Restart your machine...Hope it will work.
Thanks, Chintan(India)