EVENTLOG.WRITEENTRY THROWS AN EXCEPTION IF THE EVENT LOG IS FULL

  • Thread starter Thread starter Andy Fish
  • Start date Start date
A

Andy Fish

Sorry to shout, but I'll bet this is a common mistake when programming
windows services (or anything that uses the event log). I didn't really
think of it until our demo system wouldn't start up just before an important
demo.

What happened was this:

1. the service started OK
2. it tried to log a message saying it had started ok
3. the event log was full so WriteEntry threw an exception
4. the service caught the exception and tried to write an event log entry
saying there had been an exception
5. the event log was full so WriteEntry threw an exception again
6. the service died

Net effect: every time you try to start the service, it fails with nothing
logged in the event log - very difficult to troubleshoot.

Just like you, I could have predicted what would happen but I didn't think
of it until it was too late.

Do yourself a favor, have a look at all your code which writes to the event
log (especially exception handling code) and ask what would happen if the
event log was full.

Andy
 
Ouch, nice of you to point this out.

Sorry to shout, but I'll bet this is a common mistake when programming
windows services (or anything that uses the event log). I didn't really
think of it until our demo system wouldn't start up just before an important
demo.

What happened was this:

1. the service started OK
2. it tried to log a message saying it had started ok
3. the event log was full so WriteEntry threw an exception
4. the service caught the exception and tried to write an event log entry
saying there had been an exception
5. the event log was full so WriteEntry threw an exception again
6. the service died

Net effect: every time you try to start the service, it fails with nothing
logged in the event log - very difficult to troubleshoot.

Just like you, I could have predicted what would happen but I didn't think
of it until it was too late.

Do yourself a favor, have a look at all your code which writes to the event
log (especially exception handling code) and ask what would happen if the
event log was full.

Andy
 
Back
Top