Eventlog: Unregister Source from Application

  • Thread starter Thread starter dr34mup
  • Start date Start date
D

dr34mup

Guest
Hi all,

has anyone an idea how to remove a eventlog source completely out of the application log? I tried

System.Diagnostics.EventLog.DeleteEventSource(logSource);



But somehow the source is still registered in the application log, when I try to create it and write something in it

private readonly string logSource = "ICustomService";
private readonly string logName = "I Custom Service";

eventLog1 = new System.Diagnostics.EventLog();

System.Diagnostics.EventLog.DeleteEventSource(logSource);

if (!System.Diagnostics.EventLog.SourceExists(logSource))
{
System.Diagnostics.EventLog.CreateEventSource(logSource, logName);
}

eventLog1.Source = logSource;
eventLog1.Log = logName;
eventLog1.WriteEntry("Started", EventLogEntryType.Information);

Timer timer = new Timer();
timer.Interval = 6000; // 1min
timer.Elapsed += new ElapsedEventHandler(this.OnTimer);
timer.Start();

After I install and start the service, a new eventlog tree "I Custom Service" appears. But the 'WriteEntry' it does still write to the application log.

I also removed the registry key from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application -> I Custom Service, and restarted my machine several times now.

What I am doing wrong?

(This post is related to my previous question: Microsoft Service Tutorial: Eventlog WriteEntry crashes service )

Continue reading...
 
Back
Top