I have created an event log source using:
if (!EventLog.SourceExists(EventLogSource)) EventLog.CreateEventSource(EventLogSource);
So every log entry that uses EventLogSource goes into "Application". Then I wanted that all entries those use EventLogSource go into another custom log; so I deleted them then created source with new custom log:
try { EventLog.DeleteEventSource(EventLogSource); }
catch { }
try { EventLog.Delete(EventLogName); }
catch { }
...
if (!EventLog.SourceExists(EventLogSource)) EventLog.CreateEventSource(EventLogSource, EventLogName);
while (!EventLog.SourceExists(EventLogSource)) { }
BUT when I log using EventLogSource the entries still are going into "Application" instead of EventLogName.
Note:
I wrote this in comments and I think It helps to describe my problem better: In Windows Event Viewer you see a "Windows Logs" and "Application" is under that. There is another node in the tree named "Applications and Services Logs" which I want to create a custom log under that. I can do that successfully. The problem is that an event source that was previously registered to "Application" can not be un-registered from "Application" and re-register in my own "MyCustomLog".