1

Using the Serilog.Settings.AppSettings project I am having difficulty setting a filter to exclude certain namespaces from a configured sink.

In code I would do something like this:

[...].Filter.ByExcluding(Matching.FromSource<MyNameSpace>())

However I don't seem able to do it using the app settings.

Is this supported and if so how can I achieve this using configuration?

Thanks

Vincent

vm2013
  • 304
  • 2
  • 14

1 Answers1

1

Make sure you have the package.

Install-Package Serilog.Filters.Expressions

Then follow the example here: https://github.com/serilog/serilog-filters-expressions and https://github.com/serilog/serilog-settings-configuration/blob/dev/sample/Sample/appsettings.json#L64

"Using": ["Serilog.Settings.Configuration"],
"Filter": [
      {
        "Name": "ByIncludingOnly",
        "Args": {
          "expression": "SourceContext = 'MyNameSpace'"
        }
      }
    ]
emp
  • 4,926
  • 2
  • 38
  • 50