How to turn off the logging done by the ASP.NET core framework

后端 未结 7 1291
梦如初夏
梦如初夏 2020-12-02 11:57

How do I turn off the logging done by ASP.NET for each request e.g.

INFO 09:38:41 User profile is available. Using \'C:\\Users\\xxxx xxxx\\AppData\\L

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 12:33

    Setting Logging.LogLevel in appsettings.json for the key Microsoft was not enough. I had to specifically set the following keys specifically, e.g.:

    "Microsoft.Hosting.Lifetime": "Warning",
    "Microsoft.AspNetCore.Hosting.Diagnostics": "Warning",
    "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware": "Warning"
    

    But as an alternative using a key with a wildcard, e.g. Microsoft.*, worked. So I ended up with:

    {
      "Logging": {
        "LogLevel": {
          "Default":     "Warning",
          "Microsoft.*": "Warning" 
      }
      ...
    }
    

提交回复
热议问题