Parameter-matching is case-sensitive (sink arguments, etc)
See original GitHub issueI’m trying to set the formatter using Environment Variables, and nothing I’ve tried is working.
I was able to set it using an in-memory configuration, so I’m pretty sure the syntax is correct:
var defaultConfig = new Dictionary<string, string>
{
{ "Serilog:WriteTo:0:Name", "Trace" },
{ "Serilog:WriteTo:0:Args:formatter", "Serilog.Formatting.Json.JsonFormatter, Serilog" }
}
var builder = new ConfigurationBuilder()
.AddInMemoryCollection(defaultConfig)
.AddEnvironmentVariables("IDP_");
All of my other environment variables are loaded by configuration correctly, just not Serilog.
Any suggestions?
IDP_SERILOG__WRITETO__0__NAME='Trace'
IDP_SERILOG__WRITETO__0__ARGS__FORMATTER='Serilog.Formatting.Json.JsonFormatter, Serilog'
IDP_Serilog:WriteTo:0:Name='Trace'
IDP_Serilog:WriteTo:0:Args:formatter='Serilog.Formatting.Json.JsonFormatter, Serilog'
Adding a breakpoint, I’m able to see the values are loaded in the config object correctly
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
case-insensitive
This command indicates whether the matching patterns in the control list are case-sensitive or case-insensitive. Syntax. Value-matching is case-insensitive.
Read more >The Case For Case Insensitivity
Case sensitivity makes the programmers intent clearer - a reader won't have to guess if htmltag or HtmlTags refers to the same 'tag'....
Read more >Laravel case insensitive routes
I understand how I can make parameters like {parameter} use a regex pattern using ->with(), but that does not help me with the...
Read more >Why is the terminal case-sensitive?
So the argument that case sensitivity makes for more readable code is fallacious. It doesn't to "normal" people. It simply adds an unnecessary ......
Read more >In PowerCenter, are mapping parameters / variables case ...
The mapping parameters/variables are not case-sensitive. Therefore, two same parameters with one being in upper case and other in lower case ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to get this working. The environment variable names are case sensitive. I believe environment variable names should be case insensitive?
@josephgardner After playing around with some variations, now I see what you’re talking about – it looks like parameter-matching is case-sensitive (the “args” entries, specifically). Going back to your earlier posts, it looks like you realized this but it wasn’t clear to me from the description (no big deal, we got there in the end). I took the liberty of editing the issue title. This potentially affects all configuration sources. Now I’m reminded that’s also what I ran into working on the SQL sink. (I sometimes wonder how many millions of man-hours have been wasted on case-sensitivity…)
It turns out (fortunately for me) that this can be tested and reproduced in Windows. Even though the name of an environment variable is case-insensitive in the sense that
A
anda
can’t co-exist and either will match in a lookup, case is nonethless preserved, so the following works fortheme
but notTheme
orTHEME
:Of course, namespaces and assembly names (like Serilog.Sinks.Console above) are also case-sensitive. My concern is we’ll find both are unavoidable given that c# and the rest of the .NET stack is unrepentantly case-sensitive… but we’ll see.
I’ll take a look at the project shortly. Technically I’m supposed to be packing for a vacation, but maybe it’s an easy fix. If not, I’ll work on it next week.