Use different eventlog for a service (INSTALLUTIL)


I've written a windows service in

I need to use custom eventlog (which I can handle...).

But when I install the service using "installUtil myservece.exe" The installer creates a source for my service in the application log. WHICH I DO NOT WANT!

Installutil says:
Service myService has been successfully installed.
Creating EventLog source myService in log Application...

How can I prevent the installer from doing this, or change the eventlog in which to create this.
Who is Participating?
nauman_ahmedConnect With a Mentor Commented:
The code that I have pasted above do exactly what you were trying for :).

I am assuming you are using Visual Studio .NET.

1.  Add an event log to your service in the designer mode.
2. Right click on the event log and select properties.
3. In the Log option, write the name that you want to be appended in the EventLog viewer for your service e.g. "MyService"
4. In the source option, write the source name you want to be appeared e.g. "My Source".
5. In your class constructor, use the following:

If Not EventLog.SourceExists("MyService") Then

MyEventLog.CreateEventSource("My Source","MyService")
End IF
MyEventLog.Source = "My Source"
MyEventLog.Log = "MyService"

HTH, Nauman.
pdvdAuthor Commented:
Nauman, thank you.

I am using VS .Net.

Your solution will allow me to create logs in a different log, but i will not change the default log location for my service. There for I can not use the same name for the source in my new event log as the service name, since that has been registred to the Application event log...

I would really like to instruct my installer to "create an Evenlog source myService in log WhichEverIWant"

I can't seem to find a way for this though
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

ok.  By default event log has three type of logs:


You want that your service log should be written in a separate log say "myService"?

pdvdAuthor Commented:
Yes, indeed :0
pdvdAuthor Commented:
I got this to work btw by using a eventlog object that writes to a custom log. The serice will however keep throwing start & stop notifications in the application log.

It would be nice if I could just link the myService source to any chosen log...
All Courses

From novice to tech pro — start learning today.