I'm currently working on a legacy asp.net webservice (asmx) hosted on an IIS 10 on Windows Server 2016.
In IIS the webservice is currently running with Identity ApplicationPoolIdentity. This can be changed.
I need to log Messages into the Windows Event Viewer, I use "Application Error" as the EventSource, as it apparently is an already existing event source on windows. Therefore I refer to this post and use the following C# code:
try
{
System.Diagnostics.EventLog.WriteEntry("Application Error", "EventLog Test - Code EventLog", EventLogEntryType.Error);
}
catch (Exception ex)
{
// log error to file
}
When I run the application, I only get the following error log:
Unable to open log for source Application Error. You may not have write access.
Which settings could I adjust in IIS/registry/C# to achieve a log into my Windows Event Viewer? Do you know how to solve this error?