'How to configure Serilog's ContainsKey-Filter in a external JSON config file?
How can I configure the filter lc.Filter.ByIncludingOnly(lc => lc.Properties.ContainsKey("log_gp") in a external applicationsettings.json file? I tried
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "Contains(Properties, 'log_gp')"
}
}
]
but no success. Thanks
Solution 1:[1]
dotnet add package serilog.expressions
then:
"Using": ["Serilog.Expressions"],
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "IsDefined(log_gp)"
}
}
]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nicholas Blumhardt |
