Use case-insensitive matching for source names in level overrides
See original GitHub issue[I’m unclear if this is the right repo for this or not; I’d be happy to move or refile if needed.]
Microsoft.Extensions.Configuration is a case-insensitive construct. For example, configuration.GetSection("a:b:c")
will yield the same as configuration.GetSection("A:B:C")
. This allows things like environment variables or command line parameters to participate in config but also be named in a contextually correct fashion (e.g., environment variable A__B__C
).
In configuring the minimum level and overrides for log sources, I think I’ve discovered that the JSON configuration values are case-sensitive. For example, this…
{
"serilog": {
"minimumLevel": {
"default": "Information",
"override": {
"microsoft": "Warning",
"system": "Warning"
}
}
}
}
…does not work - it still shows informational messages from Microsoft.* sources.
However, this:
{
"serilog": {
"minimumLevel": {
"default": "Information",
"override": {
"Microsoft": "Warning",
"System": "Warning"
}
}
}
}
does work - only warnings show up for the Microsoft.* sources.
The only difference is the capitalization of the source names, which indicates the source names here are case-sensitive.
Granted, JSON itself is case-sensitive but since this is running through the MS configuration stuff, it can’t really be assumed to be case-sensitive, especially if someone configures it through the environment:
SERILOG__MINIMUMLEVEL__OVERRIDE__MICROSOFT="Warning"
Where does that comparison/filtering take place? Is that a core Serilog thing? I could throw a PR in for that if I know where to start tracking it down.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Thanks for the analysis. I don’t think it’d hurt for us to switch to case-insensitive comparisons in this case; although it would introduce a slight inconsistency with the core Serilog project’s
Matching.FromSource(string)
I think we could live with it. Fair to mark it as an enhancement, though 😄I don’t think this is a change we are likely to make in the near future; closing as stale, but thanks for raising it nonetheless. (Hope all’s well with you @tillig 👋)