在 Serilog 中设置 MinimumLevel:是否可以对命名空间使用 wildcard/regex?

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

在 Serilog 中设置 MinimumLevel:是否可以使用 wildcards/regex 命名空间?

假设我有自己的不同大小写的命名空间,这两个命名空间都需要登录信息。

可以通过这样的配置来完成吗?

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

或者这是否只能通过指定两者才能实现?

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

截至撰写本文时,最低级别覆盖功能支持wildcards/regex。它只支持简单的(case-sensitive)部分匹配。 You can see how it works in the source code.

将两个不同的命名空间声明为第二个示例是可行的方法。