I am running a .net core (6.1) console application in containers. When it tries to write to the Windows Event log, it throws this error
The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security, State.
Here is the code:
string name = "My Console App";
try
{
if (!EventLog.SourceExists(name))
{
EventLog.CreateEventSource(name, "Application");
}
EventLog.WriteEntry(name, pMessage, pEvntType);
}
catch (SecurityException ex)
{
Console.WriteLine(ex.Message);
}
I have looked at a similar issues but they are all talking about IIS. Any help