Recently I have upgraded .Net Core Web API project which was written in .Net Core 2.2 to .Net version 8.
It is a quite a jump, so had to re-write few classes to get it working.
When it finally runs, I realized that logging is not working on the upgraded app. App use to log to Windows Event Log.
Reading through this article, I found out there are few things need changing.
First of all .Net 8, web apps starts with WebApplication.CreateBuilder method. By default this method adds following logging providers:
- Console
- Debug
- EventSource
- EventLog (of course this only works on Windows platforms)
One other thing you need to pay attention is logging level. Logging level can be specified in code or in applicationSettings.json file.
As explained in above article - "Unlike the other providers, the EventLog provider does not inherit the default non-provider settings. If EventLog log settings aren't specified, they default to LogLevel.Warning."