After 3 hours of getting this message "The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security."
and trying several solutions, I am posting here. Is there a concise way to write to an event log from the WebService (asmx) running on my localhost?
I followed the instructions found on msdn and added NETWORK SERVICE using regedit, giving it read rights as per http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/416098a4-4183-4711-a53b-e10966c9801d/
Here is my code inside my Web Service
string sSource = "MyWebService";
string sLog = "Application";
string sEvent = "Sample Event";
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);
EventLog.WriteEntry(sSource, sEvent);
EventLog.WriteEntry(sSource, sEvent,
EventLogEntryType.Error, 234);