这是我的记录器配置
var loggerConfig = new LoggerConfiguration()
//.MinimumLevel
//.Information() //These are not working from appsettings.json possibly because we are using Serilog?
//.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
.ReadFrom.Configuration(configuration,"Logging")
.WriteTo.Console()
.WriteTo.File(
$"{configuration.GetValue<string>("logFilePath")}{DateTime.Now.Date:yyyy_MM_dd}_{assemblyName}.log");
var logger = loggerConfig.CreateLogger();
services.AddLogging(loggingBuilder =>
{
loggingBuilder.ClearProviders();
loggingBuilder.AddSerilog(logger);
});
这是我的 appsetting.json 的日志记录部分
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning"
}
日志记录不遵循设置级别的设置,似乎默认为信息。还尝试了以下但它没有用 “记录”:{ “最低水平”:{ “默认”:“调试”, “覆盖”:{ "系统": "信息", "微软": "信息", "Microsoft.Hosting.Lifetime": "信息", “Microsoft.EntityFrameworkCore”:“警告” } }