Skip to main content

AddConsole is obsolete: This method is retained only for compatibility

While working on a POC I got the following warning/error when trying to add some logging:

Here is the exact error message:

CS0619: ‘ConsoleLoggerExtensions.AddConsole(ILoggerFactory)’ is obsolete: ‘This method is retained only for compatibility. The recommended alternative is AddConsole(this ILoggingBuilder builder).

There are multiple ways to get rid of this warning, but I solved it by using the following code:

Happy coding!