从内存缓存消息中删除响应信息日志级别
Removing Responding from memory cache messages form info log level
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 包含大量信息消息,例如
Apr 18 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware[1000]
Apr 18 09:12:26 c202-76 kestrel-store[28711]: Request started for '/css/siteerp.css'
Apr 18 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetBuilder[1001]
Apr 18 09:12:26 c202-76 kestrel-store[28711]: Responding from memory cache for '/css/siteerp.css'
Apr 18 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware[1000]
Apr 18 09:12:26 c202-76 kestrel-store[28711]: Request started for '/lib/jquery/jquery.js'
Apr 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"
}
}
}
这似乎是从 WebOptimizer 命名空间记录的(我在 github 上检查了来源),这应该可以很容易地使用 appsettings 过滤掉。只需添加一个“WebOptimizer”键并将其设置为仅显示“警告”及更高级别。
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"WebOptimizer": "Warning"
}
}
}
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 包含大量信息消息,例如
Apr 18 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware[1000]
Apr 18 09:12:26 c202-76 kestrel-store[28711]: Request started for '/css/siteerp.css' Apr 18 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetBuilder[1001]
Apr 18 09:12:26 c202-76 kestrel-store[28711]: Responding from memory cache for '/css/siteerp.css'
Apr 18 09:12:26 c202-76 kestrel-store[28711]: #033[40m#033[32minfo#033[39m#033[22m#033[49m: WebOptimizer.AssetMiddleware[1000]
Apr 18 09:12:26 c202-76 kestrel-store[28711]: Request started for '/lib/jquery/jquery.js'
Apr 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"
}
}
}
这似乎是从 WebOptimizer 命名空间记录的(我在 github 上检查了来源),这应该可以很容易地使用 appsettings 过滤掉。只需添加一个“WebOptimizer”键并将其设置为仅显示“警告”及更高级别。
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"WebOptimizer": "Warning"
}
}
}