Stefan
EventLogAppender and log4net
Hey there,
I was looking into configuring Windows event logging for an ASP.NET Core application (running on
net8.0
) with log4net
. In brief, my log4net.config
configuration looks something like this:
I am using DI, so somewhere in my startup code I hook up log4net with options.AddLog4Net("log4net.config");
. This works fine with everything except the Windows event logger. I registered a new source via PowerShell prior to running the application with:
Also tried variants of this (-LogName Application
, etc.) to no avail. An older SO answer suggest that this is not working for .NET applications anymore (so only .NET Framework and .NET Standard compatible versions), see also:
https://stackoverflow.com/questions/61639853/c-sharp-windows-event-viewer
I looked at the source code here to confirm that:
https://github.com/apache/logging-log4net/blob/master/src/log4net/log4net.csproj#L22C23-L22C44
The project is targeting .NET Framework 4.62 and .NET Standard 2.0. So my takeaway is, that .NET (Core) does not support Windows Event Logs?4 replies