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

后端 未结 7 1304
梦如初夏
梦如初夏 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:22

    If you're using Serilog to do your .NET Core logging, you can update your appsettings.json file to set the log levels like so:

    "Serilog": {
      "MinimumLevel": {
        "Default": "Verbose",
        "Override": {
          "Microsoft": "Error",
          "System": "Error"
        }
      },
      "Properties": {
        "Application": "your-app"
      }
    }
    

    This allows you to only log errors from System/Microsoft while logging everything else as you'd like.

提交回复
热议问题