Is .NET Core 2.0 logging broken?

后端 未结 4 589
情深已故
情深已故 2020-12-29 02:25

I can\'t seem to get Trace level log information outputted after upgrading to .NET Core 2.0 (+ASP.NET Core 2.0).

In fact, if I do a dotnet new webprojec

4条回答
  •  清酒与你
    2020-12-29 02:48

    I spent almost twenty minutes to realize that since Configuration.GetSection("Logging") in the Startup.cs file reads the section "Logging" from the config in the appsettings.json file, which was configured as "Error". Changing it to "Information" or anything lower, fixed the issue.

    Here's what the appsettinsg.json file looks now:

    {
      "Logging": {
        "IncludeScopes": true,
        "Debug": {
          "LogLevel": {
            "Default": "Information"
          }
        },
        "Console": {
          "LogLevel": {
            "Default": "Information"
          }
        }
      }
    }
    

    To find out more about the levels of logging (such as in "Information"), check out this link, that also provides general information on ASP.NET Core logging.

    I'm just posting here, just in case you bump into any trouble with getting the logging to work, make sure you've been through that JSON file.

提交回复
热议问题