Use different eventlog for a service (INSTALLUTIL)

Posted on 2005-03-02
Medium Priority
Last Modified: 2012-05-05

I've written a windows service in vb.net

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.
Question by:pdvd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 25

Expert Comment

ID: 13439538
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.

Author Comment

ID: 13447676
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
LVL 25

Expert Comment

ID: 13449721
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"?

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.


Author Comment

ID: 13449895
Yes, indeed :0

Author Comment

ID: 13449921
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...
LVL 25

Accepted Solution

nauman_ahmed earned 750 total points
ID: 13451163
The code that I have pasted above do exactly what you were trying for :).


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question