How to exclude logs in Serilog .net core using filtering

135 Views Asked by At

I have enriched my logs to contain some additional information including ExceptionDetails. Now I need to exclude the logs which have 413 StatusCode inside ExceptionDetail. ExceptionDetail is contained as key-value pair inside a dictionary called Properties, which is a property of LogEvent class.

I have read the github wiki of serilog and understood this may be done using either pure C# like: Filter.ByExcluding(Matching...) or DSL syntax, but I don't know how to actually write this logic.

At this moment I have something like: .Filter.ByExcluding(Matching.WithProperty("ExceptionDetail", e => e?.ToString().Contains(""StatusCode": 413") == true))

0

There are 0 best solutions below