Writing to custom event log

V

Victor

I am writing a Windows Service Application that requires to write to a
custom event log (Tracker)

EventLog.DeleteEventSource("trkProcessMin")

' check if log exists on this machine, create a custom event
log
If Not EventLog.SourceExists("trkProcessMin") Then
EventLog.CreateEventSource("trkProcessMin", "Tracker")
End If

'create a log instance variable to manipulate the custom event
log
Me.trkMinLog.Log = "Tracker"
Me.trkMinLog.Source = "trkProcessMin"

I have set Autolog property to false, so that no logging occurs on the
default log - Application. However, event messages are posted to the
Application log, not the custom event log (Tracker)!. Furthermore, the
messages contain additional text, see below

Event Type: Information
Event Source: trkProcessMin
Event Category: None
Event ID: 0
Date: 20/10/2003
Time: 11:20:17
User: N/A
Computer: Test
Description:
The description for Event ID ( 0 ) in Source ( trkProcessMin ) cannot
be found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: Tracker tool
started.

How can I get the service write to custom event log. And why can't the
description be found in the event above?

Any help is appreciated.
 
M

Manoj G [MVP]

Hi,
Restart your machine and try again. If a source has already been mapped to a
log and you remap it to a new log, you must reboot the computer for the
changes to take effect (MSDN)
Also check the registry and check whether the event source is registered in
the right log (HKLM\System\CurrentControlSet\Services\EventLog\<<Your
log>>).
 
V

Victor

I've got the problem sorted. The autolog property for the installer
should be set to false, otherwise it registers the service to write to
application log by default.

I hope this could be made clear in the help files.

Victor.
Manoj G said:
Hi,
Restart your machine and try again. If a source has already been mapped to a
log and you remap it to a new log, you must reboot the computer for the
changes to take effect (MSDN)
Also check the registry and check whether the event source is registered in
the right log (HKLM\System\CurrentControlSet\Services\EventLog\<<Your
log>>).
--
HTH,
Manoj G [.NET MVP]
http://www15.brinkster.com/manoj4dotnet

Victor said:
I am writing a Windows Service Application that requires to write to a
custom event log (Tracker)

EventLog.DeleteEventSource("trkProcessMin")

' check if log exists on this machine, create a custom event
log
If Not EventLog.SourceExists("trkProcessMin") Then
EventLog.CreateEventSource("trkProcessMin", "Tracker")
End If

'create a log instance variable to manipulate the custom event
log
Me.trkMinLog.Log = "Tracker"
Me.trkMinLog.Source = "trkProcessMin"

I have set Autolog property to false, so that no logging occurs on the
default log - Application. However, event messages are posted to the
Application log, not the custom event log (Tracker)!. Furthermore, the
messages contain additional text, see below

Event Type: Information
Event Source: trkProcessMin
Event Category: None
Event ID: 0
Date: 20/10/2003
Time: 11:20:17
User: N/A
Computer: Test
Description:
The description for Event ID ( 0 ) in Source ( trkProcessMin ) cannot
be found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: Tracker tool
started.

How can I get the service write to custom event log. And why can't the
description be found in the event above?

Any help is appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top