Re: EventLog.Source & Service Programs
From: David Williams , VB.NET MVP (davidd.NOSPAM.williams_at_earthlink.net)
Date: 06/29/04
- Next message: Imran Koradia: "Re: How to Make a TextBox Behave..."
- Previous message: bclegg: "Failed to load resources from resource file"
- In reply to: MAL: "EventLog.Source & Service Programs"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 29 Jun 2004 16:49:13 -0700
In your OnStart function:
Dim log As EventLog
If Not EventLog.SourceExists("ServiceSourceNameOfYourChoice") Then
EventLog.CreateSource("ServiceSourceNameOfYourChoice")
End If
log = New EventLog("Application", "ServiceSourceNameOfYourChoice")
HTH
David Williams [VB.NET MVP]
"MAL" <irreverence2381@hotmail.com> wrote in message
news:a2aba623.0406282221.3cb7891@posting.google.com:
> Hello,
>
> I am writing a service program that writes to a custom EventLog. I
> would like the two classes used in the service to write messages to
> the same log ideally using a different Source name for filtering etc.
>
> So far I am having little luck. I feel that I have been through the
> documentation extensively but am chasing my tail. It seems like it
> should be as simple as .CreateEventSource in each class I want to
> write to the custom log, but to no avail.
>
> When I tried to just add one class to the service program, the service
> program wrote to the Application Log and the class wrote to the custom
> one, even though the service seemed to have created the log. (Based on
> a 5 minute timer before "Newing" my class) (.AutoLog = False) The code
> is straight from the service program and EventLog walkthroughs (which
> I end up using to clean things up (RemoveSource(s), DeleteLog) before
> my next service removal and reboot.
>
> The last thing I tried was creating a seperate EventLog in each class
> and trying to associate the source with the log the service created. I
> have attemted to pass a reference to the EventLog to the classes and
> then change the source like in the multithreaded examples. I have
> tried to bring the service pgms EventLog into scope in the classes.
> AHHHHHHH!!!
>
> I am obviously making this harder that it needs to be.
>
> Thanks for reading this rant. Please advise.
- Next message: Imran Koradia: "Re: How to Make a TextBox Behave..."
- Previous message: bclegg: "Failed to load resources from resource file"
- In reply to: MAL: "EventLog.Source & Service Programs"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|