SteeltoeOSS / InitializrConfig

Configuration store for Steeltoe.Initializr.ConfigServer
Apache License 2.0
0 stars 3 forks source link

Suggested logging levels #73

Closed ddieruf closed 3 years ago

ddieruf commented 3 years ago

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.

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information",
      "Steeltoe": "Information",
      "example_app": "Debug"
    }
  }
}

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.

ccheetham commented 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.

ddieruf commented 3 years ago

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.

ccheetham commented 3 years ago

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"
    }
  }
}
ddieruf commented 3 years ago

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.

ccheetham commented 3 years ago

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.

ddieruf commented 3 years ago

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.