I create event logs for asp.net projects error logging. I do it by adding a key in regedit, and then a sub-key.
Sometimes, I create a new key and sub-key, and instead of getting a new, empty event log, I see in the event viewer that it's showing me the logs from a different project. I'm not able to find a pattern as to when this happens.
Has anyone encountered such a problem? Am I doing something wrong?
views:
116answers:
2
+2
A:
You probably want to use the EventLog.CreateEventSource API to do this - it should take care of any details for you.
A quick read thru the docs seems to show that the 1st 8 characters are checked for uniqueness...perhaps that's where your issue is?
Edit: From Reflector, the API does this...
- Check for invalid characters ("non printable" based on Unicode category, \, *, ?)
- Checks that the created reg key will be <= 254 characters
- Checks if the source is already registered
- Checks that the log name isn't reserved (AppEvent, SecEvent, SysEvent)
- Checks for another log with the same beginning 8 chars
- Checks that the log name doesn't exist as a source
- Creates the log subkey
- Initializes the log subkey with default values (MaxSize = 524288, AutoBackupLogFiles = 9. Retention = 604800, File = %SystemRoot%\System32\config\logName.Substring(0, 8) + ".evt")
- If OS is not > Windows NT 5.x (Vista or higher), creates a multi string value on the logkey with logName and source name. Or, if value exists, appends source name to the existing array.
- Creates a subkey for source
- Initializes the source subkey with default values (EventMessageFile, ParameterMessageFile, CategoryMessageFile, CategoryCount)
Mark Brackett
2008-12-10 09:34:36
Thank you, but it happens even when the event logs have totally different names...
Lea Cohen
2008-12-10 10:11:42
If there are any registry keys you're not aware of, or other housekeeping that needs to be done when creating an event log, the API will do it, where as you may be omitting a crucial step with your manual process.
Patrick Cuff
2008-12-10 12:06:55
A:
It seems that the problem was that we had already created an event log with that name, and even though we deleted it, it didn't help. The solution was to create an event log with a different name.
Lea Cohen
2009-02-15 08:34:36
If you'd done what Mark Bracket suggested 2.5 months before this answer, an exception stating exactly this would have been thrown. I'll downvote this, not because it's incorrect, but because you rather marked your own - late - answer as the correct one rather than one that would just as well have helped you solve your problem.
Tomas Lycken
2010-07-15 14:07:11