I have the following filter configuration setup for serilog:
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "RequestPath = '/api/maat'"
}
},
{
"Name": "ByExcluding",
"Args": {
"expression": "RequestPath = '/swagger%'"
}
},
{
"Name": "ByExcluding",
"Args": {
"expression": "RequestPath = '/hangfire%'"
}
},
{
"Name": "ByExcluding",
"Args": {
"expression": "RequestPath = '/serilog-ui%'"
}
}
]
This excludes the api/maat
endpoint and endpoints pertaining to hangfire, swagger and serilog-ui. Unfortunately this only works for api/maat
, and does not work for the other endpoints. I'm unsure why.
If i'm hitting all endpoints the console shows the following:
How can i fix this?
I ended up fixing the issue by moving it all into a singular filter, instead of spread out into multiple, and by using StartsWith
:
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "RequestPath = '/api/maat' or StartsWith(RequestPath, '/swagger') or StartsWith(RequestPath, '/hangfire') or StartsWith(RequestPath, '/serilog-ui')"
}
}
]