我见过使用 XML 进行过滤的多个示例,但我使用 appsettings.json 进行所有配置。我已经能够实现单个when 过滤器,但是当我尝试添加额外的过滤器时,我收到重复的键错误。有任何想法吗?
这有效 -
"rules": [
{
"logger": "*",
"minLevel": "Debug",
"writeTo": "db",
"filters": {
"when": {
"condition": "equals('${event-properties:sublevel}','diagnostic')",
"action": "Ignore"
}
}
}
]
Run Code Online (Sandbox Code Playgroud)
NLog.Extensions.Logging 1.7.2 已修复此限制,现在支持此工作示例:
"rules": [
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "Console",
"filterDefaultAction": "Log",
"filters": [
{
"type": "when",
"condition": "equals('${event-properties:sublevel}','diagnostic')",
"action": "Ignore"
},
{
"type": "when",
"condition": "contains('${message}','HeartbeatResponse')",
"action": "Ignore"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2051 次 |
| 最近记录: |