1

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.

  • MyNameSpace
  • MYNameSpace

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"
      }
    }
  }
jps
  • 20,041
  • 15
  • 75
  • 79
Stef Heyenrath
  • 9,335
  • 12
  • 66
  • 121
  • Just thinking out loud - Given that c# is case sensitive and so are namespace names, you're referring to 2 different namespaces so does it not make sense that the second sample would be 'better'? Although i see that this can get confusing... – sommmen Oct 28 '20 at 10:45

1 Answers1

2

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.

C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91