Why is Logger not automatically available as DI service
Posted By: Anonymous When trying to instantiate public class MyClass : BackgroundService { private ILogger<MyClass> Logger {get;} public MyClass(Logger<MyClass> logger) { Logger = logger } } through .Net DI by registering MyClass through services.AddHostedService<MyClass>(); When the class is activated, an exception is thrown: System.InvalidOperationException: ‘Unable to resolve service for type ‘Microsoft.Extensions.Logging.Logger1[MyClass]’ while attempting to activate …