Reputation: 22535
I am creating a Windows service, and am writing to the event log.
Here is how I create it:
if (!System.Diagnostics.EventLog.SourceExists("MySource"))
{
System.Diagnostics.EventLog.CreateEventSource(
"MySource", "MyNewLog");
}
eventLog1.Source = "MySource";
eventLog1.Log = "MyNewLog";
Here is how I write to the eventLog:
eventLog1.WriteEntry("In OnStart");
How can I find the file where this line is written? I tried to go to the Event Viewer but it only shows that the services stops and starts.
Upvotes: 1
Views: 11988
Reputation: 33149
Your entry should show up in the Event Viewer (if the code runs under account with local Admin rights), but to answer your question, the event log files are stored in your
%SystemRoot%\System32\Config
folder as *.evt
files.
Upvotes: 1
Reputation: 716
The app/service will need to run elevated at least once to create the log (unless you have UAC disabled), otherwise the CreateEventSource() will silently fail.
Upvotes: 0