Custom Event Log  
Author Message
DotNetDon





PostPosted: .NET Base Class Library, Custom Event Log Top

I have written a Windows Service which writes to a custom event log. When I install the service for some reason it automatically adds my app as a source to the "Application" event log in the registry. When I start my app I immediately delete the source and re-create it under my custom log. Unfortunately I have to reboot the computer for the change of source to take effect.

My question is, why does the installation of a service automatically add the source to the application Event log Is there a way to suppress this step Is there a way to instruct the setup package to register the source to the correct log

If only the setup process would not add the source to the application log, then I would not have to worry about running my app once and then rebooting the machine.

Thank You,

Don



.NET Development6  
 
 
arch_angel81





PostPosted: .NET Base Class Library, Custom Event Log Top

I would also like to know the solution to this as I am having the same problem.

 
 
nobugz





PostPosted: .NET Base Class Library, Custom Event Log Top

Why do you use EventLogInstaller separately Are you not happy with the one that ServiceInstaller automatically creates for you I don't see any property in ServiceInstaller nor a command line switch for InstallUtil.exe to prevent this from happening...


 
 
Thilak Nathen





PostPosted: .NET Base Class Library, Custom Event Log Top

ServiceBase (which your service derives from) provides a property called EventLog. The easiest way for you do what you want to do is to set up that EventLog property appropriately and write to that.

e.g.

public partial class MyService: ServiceBase
{


public MyService()
{
EventLog.Source = "MySource";
EventLog.Log =
"MyCustomLog"; //Default is Application
}

}


 
 
DotNetDon





PostPosted: .NET Base Class Library, Custom Event Log Top

The event log ServiceInstaller automatically creates my app as a source to the application log. I don't want the source registerd to this log, but rather to a custom event log. I tried using the EventLogInstaller to override the automatic source registration, but this does not work as the source is already registered. I am just trying to override this automatic registration so my app will be correctly registered to a custom event log.