我已经这样配置应用程序登录:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
...
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging((context, logging) =>
{
logging.ClearProviders();
if (context.HostingEnvironment.IsDevelopment())
{
logging.AddConsole();
}
else
{
logging.AddAzureWebAppDiagnostics();
}
logging.SetMinimumLevel(LogLevel.Information);
logging.AddFilter((category, level) =>
{
if (category.Contains("Microsoft") && level > LogLevel.Information)
{
return true;
}
else
{
return false;
}
});
})
.ConfigureServices(serviceCollection =>
serviceCollection.Configure<AzureBlobLoggerOptions>(options =>
{
options.BlobName = $"auditLog-{DateTime.Today:dd-MM-yy}.txt";
})
);
但是,我面临两个问题:
如何配置到Azure Blob的日志记录,使其仅包含由应用程序生成的日志,而不包括所有Microsoft和系统 Information 级别的日志?