【问题标题】:Removing Responding from memory cache messages form info log level从信息日志级别的内存缓存消息中删除响应
【发布时间】:2021-07-12 16:38:16
【问题描述】:

ASP.NET Core 5 MVC 应用程序在 Debian linux 中使用 Weboptimizer (https://github.com/ligershark/WebOptimizer)。

在 startUp.cs 我有:

    public void ConfigureServices(IServiceCollection services)
    {
        ...
        services.AddWebOptimizer();
        ...
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    { 
        ...
        app.UseWebOptimizer();
        ...
    }

syslog 包含大量的信息消息,例如

4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:#033[40m#033[32minfo#033[39m#033[22m#033[49m:WebOptimizer.AssetMiddleware[1000]]

4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:对“/css/siteerp.css”的请求已开始 4 月 18 日 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetBuilder[1001]]

4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:从内存缓存中响应“/css/siteerp.css”

4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:#033[40m#033[32minfo#033[39m#033[22m#033[49m:WebOptimizer.AssetMiddleware[1000]]

4 月 18 日 09:12:26 c202-76 kestrel-store[28711]:请求已启动“/lib/jquery/jquery.js”

4 月 18 日 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetBuilder[1001]]

如何只为 WebOptimizer 禁用这些消息以使日志更紧凑?我还没有找到任何关于日志配置的文档。

使用默认的 appsettings.json:

{

  "AllowedHosts": "*",
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }

  }
}

【问题讨论】:

    标签: asp.net-core .net-core asp.net-core-mvc kestrel-http-server weboptimizer


    【解决方案1】:

    这似乎是从 WebOptimizer 命名空间(我检查了 github 上的源代码)记录下来的,这应该可以很容易地使用 appsettings 过滤掉。只需添加一个“WebOptimizer”键并将其设置为仅显示“警告”或更高。

    {
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information",
          "WebOptimizer": "Warning"
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      • 2011-03-09
      • 1970-01-01
      • 2022-01-25
      相关资源
      最近更新 更多