I have an ApplicationConfigurationSettings class which I am binding the values from the appsettings.json file to. I can get everything bound except the logger LogLevel value, most likely due to the existence of a sub level in the json format of Logging entry.
I bind the class as follows
services.Configure<ApplicationConfigurationSettings>(Configuration.GetSection("ApplicationConfiguration"));
appsettings.json (parts removed for brevity)
{
"ApplicationConfiguration": {
"ConnectionStrings": {
"DevelopmentConnection": "Server=(localdb)\\mssqllocaldb;Database=TestingConfigurationNetCoreTwo_Development;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"ApplicationIconUrls": {
"MaleUserIcon": "https://machineryrestorations.blob.core.windows.net/publicfiles/images/BestMaleUser_32x32.png",
"FemaleUserIcon": "https://machineryrestorations.blob.core.windows.net/publicfiles/images/BestFemaleUser_32x32"
},
"ApplicationInfo": {
"VersionNumber": "1.0.0",
"Author": "Jimbo",
"ApplicationName": "CustomTemplate",
"CreatedOn": "November 20, 2017"
}
}
}
My logger POCO
public class LoggerSettings
{
public bool IncludeScopes { get; set; }
public KeyValuePair<string,string> LogLevel { get; set; }
}
I'm sure it is due to the fact that the binder can't reconcile my LogLevel property with what is in the json file. How can I change my logger POCO to get this to work since I cannot change the Logging format in the json file?
This is how the json provider resolves it when inspecting Configuration from
services.AddSingleton(Configuration);
{[ApplicationConfiguration:Logging:IncludeScopes, False]} {[ApplicationConfiguration:Logging:LogLevel:Default, Warning]}
I just can't seem to set that property up properly in the class so it binds correctly.