Should a window service use its own evenl log?

  • Thread starter Thread starter Julia
  • Start date Start date
J

Julia

Hi,

I am writing a window service and I wonder should I use my own event log
or should I use one of the predefined event logs?

Thanks in advance
 
I always find it more convenient to write to my own even log, it keeps it in
seperate from other system event logs and gives you the flexibility to write
the information you want to see in there. If you design it properly, you
can always change you logging code later to log to a database for example.
 
Hi Julia,

I think that it entirely depends on what you are logging. If it is a
minimal amount of information that you are logging (e.g. Service x started,
Service x error..,etc) and the information fits one of the existing logs I
believe that using an existing log would be fine. If you are logging an
extensive amount of information that would clutter the existing logs or
doesn't match the content I believe that it would be best to go with your own
log. Just my opinion.

Hope this helps.
-------------------
 
Yes, i am thinking to log to the event log only "Service X
started\stopped.",
error and exceptions
and other stuff will goes to a log file

Thanks.
 
when a windows service starts or stops it is automatically logged to the
'System' event log.

HTH

Ollie Riches
 
Ollie,
Entries are also written to the 'Application' event log, unless you override
the ServiceBase.EventLog property & return a custom event log.

http://msdn.microsoft.com/library/d...rviceprocessservicebaseclasseventlogtopic.asp

By overriding ServiceBase.EventLog & returning a NEW event log object you
can change where the AutoLog entries are written. The above page suggests
you cannot, however I believe the above page is referring to the fact you
cannot (should not) change the EventLog returned from the
ServiceBase.EventLog property, you need to return a new one!

NOTE: The entries written to the 'System' event log are still written
there...

Hope this helps
Jay
 
Back
Top