I am trying to specify this filter in the appsettings .json file
.Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Hosting.Internal.WebHost"))
The above syntax works when specified in c#
But trying to specify the same in a json file does not work.
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "Matching.FromSource = 'Microsoft.AspNetCore.Hosting.Internal.WebHost'"
}
}
You need to use Serilog.Expressions for this:
Install-Package Serilog.Expressions
The filter section in appsettings.json looks like:
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "SourceContext = 'Microsoft.AspNetCore.Hosting.Internal.WebHost'"
}
}
],
In this specific case, I'd suggest considering level overrides as an alternative that will turn off a specific namespace more efficiently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With