在我的seq日志中没有设置属性,我找不到通过appsettings.json设置它们的方法。我可以用方法设置它们
.Enrich.WithProperty(“App”,“缺席服务”)
但对于dotnet核心依赖注入,我更喜欢在appsettings.json中设置它看起来像这样:
"Seq": {
"ServerUrl": "xxxx",
"ApiKey": "xxxx",
"MinimumLevel": "Warning",
"LevelOverride": {
"Microsoft": "Error"
}
}
如何设置appsettings.json中的应用程序或环境等属性?
您可以在应用程序启动时将appsettings配置值写入记录器配置。
var logConfig = new LoggerConfiguration()
.WriteTo.Seq(Configuration.GetValue<string>("Seq:ServerUrl"),
apiKey: Configuration.GetValue<string>("Seq:ApiKey"),
bufferBaseFilename: Configuration.GetValue<string>("Seq:BufferFilename"),
controlLevelSwitch: levelSwitch);
您的配置格式看起来会很好。