I have some code like this:
EventLog.CreateEventSource("myApp", "myAppLog");
EventLog.WriteEntry("myApp", "Test log message", EventLogEntryType.Error);
Now, unless I'm missing something having read MSDN, this should cause a new log 'myAppLog' to be created in the event viewer, and an entry should be added to that new log with the source name 'myApp'. But, I can't get the new log to be created. This always just writes an error log message to the Application log, with the source 'myApp' - 'myAppLog' is nowhere to be seen. What am I doing wrong? I am logged in as an Administrator.
Is it possible that you already used the source "myApp" when writing to the standard Application log? If so according to MSDN:
http://msdn.microsoft.com/en-us/library/2awhba7a.aspx (about half way down the page)
If you have checked all suggestions in other answers, then read the following
From MSDN
Make sure that the first 8 characters are unique.
Basically, the simplest solution is you have to close your visual studio and run as administrator mode. Then, you would be able to resolve this error
I have just written a little code to help me out of this. source registered in another log issue which I have encountered and don't want to manually have to remove sources from logs. What I decided to do was check if the source exists, if it does check that its linked to the correct log, if it isn't delete the source, now that it doesn't exist or f it never did create the Log brand new.
Hopefully it helps :)
Did you set the source on your EventLog?
From MSDN Article.
You might be forgetting to set the Source property on your EventLog.
It should look something like this:
Here's the MSDN article for reference.