-
Notifications
You must be signed in to change notification settings - Fork 131
Allow an array-style config format for Serilog:MinimumLevel:Override #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue may be moved into serilog-settings-configuration repo. |
The new syntax is a bit cumbersome and decreases UX. Since "Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
} Did you hit some strength length limit on keys? In Azure app configuration, the restriction on key-value pair is 10Kb |
"decreases UX"? Nonsense, the old format is still available, this is simply an addition. I don't know what Azure is doing to my config setting but it seems to limit them to about 61 characters so yes there is a limit. "array doesn't prevent use of duplicate keys" |
@skomis-mm In general, I agree with your comments and foresaw them, because I myself reason the same way.
Does it really decrease UX so much?
The reason is to assign a some name for the key and value. In fact, the name can be any, but for clarity, I chose the most obvious.
Agree. But if you go up one level, nothing prevents you from setting the same settings key with different values from different providers (file, env, comand line). This is a common practice of overriding configuration. Therefore, it makes little sense to defend against it. |
I think any issue Serilog suffers here is going to be shared by Microsoft.Extensions.Logging, which uses the same layout for overrides, so hopefully the Azure web app limitation will be spotted and lifted by the good folks at Microsoft. Raising an issue with them might speed this along, @jez9999. Adding more variations to the configuration syntax makes it more complicated to define, document, and learn, hence @skomis-mm's concern about UX, I think. We don't have the time here for the "nonsense", "so what?" combative style of communication; it drains the energy out of open source projects. I've responded to similar recent comments here and here. Life's too short for more of this, let's start afresh if necessary, closing. |
New syntax other than adding more verbosity won't do any better for environment variables. For one level override:
We have an old issue to overcome current current syntax and simplify it, not to add complexity to it. |
How is that an argument against this configuration option? People use Serilog becuase it offers stuff the default logging doesn't. If a better configuration is one such thing, so much the better.
Sorry, I just don't see this as any kind of problem. It's trivial to document an array-style format.
I really get the impression that you're just objecting for the sake of argument here. The point is to have a configuration option that avoids the need for periods in the key name, and avoids the need for long key names. Your objections aren't part of the problem being solved.
There's no fundamental way to "overcome" the syntax issue of putting the namespace in the key name other than to move it to being a key value. |
At the moment, the way you specify Serilog's minimum level overrides in configuration is in the following format:
The source context (or 'namespace') is specified in the setting name, rather than a value. The trouble with this is that not all configuration providers lend themselves to having long, complex configuration key names. For example, I've tried to configure the equivalent to this on an Azure web app (using the double-underscore namespace separator as a replacement for the colon), and the best I could get to was:
On my local machine, which is using
appsettings.json
, this is how it (correctly) looks:The dots have been replaced with underscores, and more importantly there is a very restrictive length limit on config key names from these environment variables. So I think the solution is not to try and put complex/long information like a namespace in the key name, but as a key value. Thus, I propose that Serilog support the following syntax for minimum level overrides:
When Override is an array, it takes a set of objects with SourceContext/Level that specify the override level for the given source context. This results in the following kind of config structure, which works even with config providers that have restrictive key names:
The text was updated successfully, but these errors were encountered: