“ILoggingBuilder”不包含“AddEventLog”的定义

AG7*_*G70 1 asp.net-core

我正在尝试在 ASP.NET Core 3.1.3 上使用 AddEventLog for Worker Service 我已经安装了 NuGet Microsoft.Extensions.Logging.EventLog

问题是我收到错误“ILoggingBuilder”不包含“AddEventLog”的定义

这是我的代码:

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseWindowsService()
    .ConfigureLogging((context, logging) =>
    {
        logging.AddEventLog(new EventLogSettings()
        {
            SourceName = "MySource",
            LogName = "MyLogName"
        });
    })

    .ConfigureServices((hostContext, services) =>
    {
        services.AddHostedService<Worker>();
    });
}
Run Code Online (Sandbox Code Playgroud)

AG7*_*G70 5

需要添加“using Microsoft.Extensions.Logging;”,奇怪的是VS 2019在“显示潜在修复”(CTRL + .)处没有识别出“using Microsoft.Extensions.Logging”的需要;