Link to home
Start Free TrialLog in
Avatar of pdvd
pdvd

asked on

Use different eventlog for a service (INSTALLUTIL)

Hi,

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.
Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

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.
Avatar of pdvd
pdvd

ASKER

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
ok.  By default event log has three type of logs:

Application
Security
System

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

-Nauman.
Avatar of pdvd

ASKER

Yes, indeed :0
Avatar of pdvd

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial