Unable to resolve ILogger from Microsoft.Extensions.Logging
问题 I've configured my console application's Main like so var services = new ServiceCollection() .AddLogging(logging => logging.AddConsole()) .BuildServiceProvider(); And then I try to use it in another class like so private readonly ILogger _logger; public MyClass(ILogger logger) { _logger = logger; } public void MyFunc() { _logger.Log(LogLevel.Error, "My Message"); } System.InvalidOperationException: 'Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' I've tried the