question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.

Info still shows up though the configuration is set to Warn

However, this:

{
  "serilog": {
    "minimumLevel": {
      "default": "Information",
      "override": {
        "Microsoft": "Warning",
        "System": "Warning"
      }
    }
  }
}

does work - only warnings show up for the Microsoft.* sources.

Only Warn is showing for 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:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
nblumhardtcommented, Jun 26, 2019

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 😄

1reaction
nblumhardtcommented, Mar 29, 2023

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 👋)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting the MinimumLevel in Serilog: is it possible to use ...
1 Answer 1 ... The minimum level override feature does not support wildcards/regex as of this writing. It only supports simple (case-sensitive) ...
Read more >
Amazon Redshift now supports case-insensitive collation ...
Amazon Redshift, a fully-managed cloud data warehouse, now supports case-insensitive collation with column and expression level overrides. Starting today, you ...
Read more >
Setting Overrides - TechDocs
Nothing outside of quotes is case sensitive (attribute names, function names, textual operators, etc.) User Classes. The evaluator supports.
Read more >
enable_case_sensitive_identifier - Amazon Redshift
Activates a configuration value that determines whether name identifiers of databases, tables, and columns are case sensitive.
Read more >
Case insensitive string comparisons should be made ...
Using toLowerCase() or toUpperCase() to make case insensitive comparisons is inefficient because it requires the creation of temporary, intermediate String ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found