-
Notifications
You must be signed in to change notification settings - Fork 308
Difference in behavior between UseConfiguration and ConfigureAppConfiguration #1148
Comments
I think the |
That about covers it. The distinction is somewhat arbitrary at this point. |
So I guess we are happy with this behaviour and can close the issue? Or is there any possible improvement in the user experience here. |
This is by-design. |
I think this is very confusing. {
"server.urls": "http://localhost:12345",
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Trace"
}
}
} With var config = new ConfigurationBuilder().AddJsonFile("appsettings.json") and var host = new WebHostBuilder().UseConfiguration(config)
var host = new WebHostBuilder().ConfigureLogging((context, logging) =>
{
logging.AddConfiguration(context.Configuration.GetSection("Logging"))
} won't apply Log settings. With var host = new WebHostBuilder()
.configureAppConfiguration((context, config) =>
(
config.AddJsonFile("appsettings.json", true, true)
})
.configureLogging((context, logging) =>
{
logging.AddConfiguration(context.Configuration.GetSection("Logging"));
)) I can inject log settings, but not Or am I seeing this wrong? |
If you can read the |
-2 to that design... |
It's still unclear to me when to use
Reading the comments, you'd think that you need to use
That must mean it's using |
That UseKestrel lamda is delay executed after both UseConfiguration and ConfigureAppConfiguration, so it's able to consume config from either source. Note it only reads the new "Kestrel" config section. "server.Urls" is awkward because kestrel doesn't read it directly, the host reads it after UseConfiguration and before ConfigureAppConfiguration and then passes it through a side channel (IServerAddressesFeature) to servers. Since the new "Kestrel" config section works with appsettings.json and is so much more powerful we opted not to rework "server.Urls" to work with appsettings.json, it's redundant. |
It's not clear and should be documented when to use one over another. |
Ran into this while investigating aspnet/AzureIntegration#81.
Code:
Output:
Note that it bound to the default address.
If I change the code to:
It behaves as expected (binds to
http://localhost:12345
):Is this by design?
The text was updated successfully, but these errors were encountered: