在asp.net core 2.2中,我可以使用ClearProviders
禁用默认日志记录,如下代码:
static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(config => {
config.ClearProviders();
})
.UseStartup<Startup>();
但是我在asp.net core 3.0中找不到ClearProviders
如何在asp.net core 3.0中做到这一点?
答案 0 :(得分:4)
根据documentation,ASP.NET Core 3.0支持ClearProviders()。
也许您很想念using Microsoft.Extensions.Logging;
。
答案 1 :(得分:0)
尝试将IWebHostBuilder更改为IHostBuilder。还要将WebHost更改为主机
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging((logging) =>
{
// clear default logging providers
logging.ClearProviders();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});