gpt4 book ai didi

asp.net-core - 使用 appsettings.json 覆盖特定接收器的 serilog minimumlevel

转载 作者:行者123 更新时间:2023-12-03 23:15:29 25 4
gpt4 key购买 nike

在代码、xml 和 json 中有“全局”覆盖 MinimumLevel 的文档。 .

但是我可以使用 appsettings.json 覆盖特定的接收器吗? ?例如,我想在类 MyClass 的警告级别登录,但仅适用于控制台接收器。

最佳答案

只需使用 受限于最低级别 特定接收器的配置部分中的参数:

{
/* .. */
"Serilog": {
"MinimumLevel": {
"Default": "Verbose", /* <-- set the default level to the LOWEST applicable for your app */
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console",
"restrictedToMinimumLevel": "Information" /* <-- set the minimum level for specific sink */
}
},
{
"Name": "File",
"Args": {
/* .. */
"restrictedToMinimumLevel": "Warning" /* <-- set the minimum level for specific sink */
}
},
{
"Name": "Udp",
"Args": {
/* .. */
"restrictedToMinimumLevel": "Warning" /* <-- set the minimum level for specific sink */
}
}
],
/* .. */
}
}

关于asp.net-core - 使用 appsettings.json 覆盖特定接收器的 serilog minimumlevel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51816895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com