Reputation: 133
I've seen examples of multiple when filters using XML but I'm using appsettings.json for all configuration. I've been able to implement a single when filter but when I try to add an additional filter I get a duplicate key error. Any ideas?
This works -
"rules": [
{
"logger": "*",
"minLevel": "Debug",
"writeTo": "db",
"filters": {
"when": {
"condition": "equals('${event-properties:sublevel}','diagnostic')",
"action": "Ignore"
}
}
}
]
Upvotes: 6
Views: 2805
Reputation: 36770
This limitation has been fixed with NLog.Extensions.Logging 1.7.2, that now supports this working example:
"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"
}
]
}
]
Upvotes: 6