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.

Parameter-matching is case-sensitive (sink arguments, etc)

See original GitHub issue

I’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 image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
josephgardnercommented, May 9, 2018

I was able to get this working. The environment variable names are case sensitive. I believe environment variable names should be case insensitive?

    environment:
      - IDP_Serilog__MinimumLevel=Debug
      - IDP_Serilog__WriteTo__0__Name=Trace
      - IDP_Serilog__WriteTo__0__Args__formatter=Serilog.Formatting.Json.JsonFormatter, Serilog
1reaction
MV10commented, Aug 29, 2018

@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 and a can’t co-exist and either will match in a lookup, case is nonethless preserved, so the following works for theme but not Theme or THEME:

image

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.

Read more comments on GitHub >

github_iconTop 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 >

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