Finally worked out my problem with Windows Events

For a while now I’ve been trying to use Windows Events as my logging framework, but I have suffered from one seemingly fatal problem: if my application terminated unexpectedly (thus ungracefully), my session was left open, and I was seemingly unable to stop it or re -enable providers against it. This was beginning to make me feel like Windows Events was not the right framework for debug logging, because an ungraceful termination is very likely during development. However, I have since found that I was not passing the name I thought I was to the StartTrace function, and so although I could close my session as long as my application didn’t terminate (due to some state in my logging class), a “Cold-Stop” (as in a ControlTrace call at the start of my app) would not work.

I have now corrected this bug in my code, and can now close the open session and restart it if I encounter ERROR_ALREADY_EXISTS upon starting my session.

WIN!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s