我在 Pivotal Cloud Foundry 中有 ASP.NET Core 2.1 应用程序,我们希望能够在其中动态配置日志记录级别。作为记录器提供商,我们使用 Serilog。 Steeltoe 动态记录是否可以与第 3 方记录器一起正常工作以及如何工作?
这是我尝试过的:
在Program.cs中:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseCloudFoundryHosting()
.ConfigureLogging((builderContext, loggingBuilder) =>
{
loggingBuilder.AddDynamicConsole();
})
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
.ReadFrom.Configuration(hostingContext.Configuration))
.UseStartup<Startup>();
在 appsettings.json 中
"Serilog": {
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {SourceContext}: {Properties} {NewLine} {EventId} {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
}
在 appsettings.Development.json 中:
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
我在配置日志级别中只得到这个:配置日志记录级别屏幕截图 https://i.stack.imgur.com/jgRwV.png
我究竟做错了什么?
我在这里添加了对 Steeltoe 的 Serilog 支持:https://github.com/SteeltoeOSS/Logging/pull/4 https://github.com/SteeltoeOSS/Logging/pull/4
如果它解决了您的问题,请告诉我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)