Closed ddieruf closed 3 years ago
The recommendation for setting the project's namespace logging is useful.
Since a Debug
setting seems better targeted to an appsettings.Development.json
file, we'll set the default level to Information
.
This issue has also highlighted that the default logging level is Debug
which is incorrect. It has been updated to Warning
. Other loggers beside the project's and the default will be removed.
Other loggers beside the project's and the default will be removed.
I suggest keeping the defaults created from dotnet new
, but adding in the Steeltoe and app values.
Something like:
$ cat appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Steeltoe": "Warning",
"{{name}}": "Information"
}
},
"AllowedHosts": "*"
}
$ cat appsettings.Development.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Steeltoe": "Warning",
"{{name}}": "Debug"
}
}
}
That's a winner. If I was going to get picky I might suggest turning Steeltoe up to "Debug" in appsettings.Development.json. But I'm not, so I won't.
Don't necessarily disagree. In the end it seemed the Steeltoe
libraries are more playing a role akin to Microsoft
libraries than they are to the project itself.
Agreed.
In the past I have found that some packages gave me specific feedback I needed as to why my app wasn't connecting properly (like discovery & config). Thats all, probably not a huge diver there.
When you create a new webapi the default logging levels and packages to monitor are pretty basic. Initializr can go a bit deeper because it knows more about what the project is doing. I suggest adding in some additional logging packages as a default to all projects Initializr creates in appsettings.json.
PS - It would be nice to include different appsettings for different environments (appSettings.Development.json). Then you could adjust the logging levels of each package for the given context.