Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger`1[WebApplication1.Startup]'

前端 未结 5 2191
轮回少年
轮回少年 2021-02-05 12:29

I created an ASP.NET Core 3.0 Web Application with the default template in Visual Studio 2019 Preview 2.2 and tried to inject an ILogger in Startup:

namespace We         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 13:09

    Unfortunately, it's not possible to inject ILogger into Startup.cs in ASP.NET Core 3.0 anymore.

    https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#capture-ilogger-logs-from-startupcs-and-programcs-in-aspnet-core-apps

    Note

    In ASP.NET Core 3.0 and later, it is no longer possible to inject ILogger in Startup.cs and Program.cs. See https://github.com/aspnet/Announcements/issues/353 for more details.

提交回复
热议问题