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

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

    I'm not sure if I am missing something but don't you just want to raise the log level for the Microsoft logs?

    Edit appsettings.json (assumes .AddJsonFile("appsettings.json", ...))

    {
      "Logging": {
        "IncludeScopes": false,
        "LogLevel": {
          "Default": "Trace",
          "System": "Information",
          "Microsoft": "Information"
    

    To

    {
      "Logging": {
        "IncludeScopes": false,
        "LogLevel": {
          "Default": "Trace",
          "System": "Information",
          "Microsoft": "None"
    

    Or the same modification via environment variables (assumes .AddEnvironmentVariables())

    Logging:LogLevel:Microsoft=None
    

    You can also be more specific, the following reduces most entries but leaves Microsoft.AspNetCore.Hosting.Internal.WebHost at Information.

    "Microsoft": "Information",  
    "Microsoft.AspNetCore.Mvc.Internal": "Warning",
    "Microsoft.AspNetCore.Authentication":  "Warning"
    

    Appologies if this doesn't work for log4net

提交回复
热议问题