regexoverridingwildcardseriloglog-level

Setting the MinimumLevel in Serilog: is it possible to use a wildcard/regex for the namespace?


Setting the MinimumLevel in Serilog: is it possible to use wildcards/regex the namespace ?

Let's assume that I have my own namespaces with different casing, which need both to be logged on Information.

Can this be done via the configuration like this?

"SeriLog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Default": "Warning",
        "MyNameSpace|MYNameSpace": "Information"
      }
    }
  }

Or is this only possible by specifying both?

"SeriLog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Default": "Warning",
        "MyNameSpace": "Information",
        "MYNameSpace": "Information"
      }
    }
  }

Solution

  • The minimum level override feature does not support wildcards/regex as of this writing. It only supports simple (case-sensitive) partial matching. You can see how it works in the source code.

    Declaring the two different namespaces as your second example is the way to go.