问题描述
ASP.NET Core 5 MVC 应用程序使用 Weboptimizer (https://github.com/ligershark/WebOptimizera>) 在 Debian linux 中.
在 startUp.cs 中,我有:
public void ConfigureServices(IServiceCollection services){...services.AddWebOptimizer();...}公共无效配置(IApplicationBuilder 应用程序,IWebHostEnvironment 环境){...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:
{允许的主机":*",记录":{日志级别":{默认":信息",微软":警告",Microsoft.Hosting.Lifetime":信息"}}}
这似乎是从 WebOptimizer 命名空间(我检查了 github 上的源代码)记录的,这应该可以使用 appsettings 轻松过滤掉.只需添加一个WebOptimizer"即可键并将其设置为仅显示警告"和更高.
{记录":{日志级别":{默认":信息",微软":警告",Microsoft.Hosting.Lifetime":信息",WebOptimizer":警告"}}}
ASP.NET Core 5 MVC application uses Weboptimizer (https://github.com/ligershark/WebOptimizer) in Debian linux.
In startUp.cs I have:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddWebOptimizer();
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseWebOptimizer();
...
}
syslog contains large number of information messages like
How to disable those messages for WebOptimizer only to make log more compact? I havent found any documentation about log config.
Default appsettings.json is used:
{
"AllowedHosts": "*",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
This seems to be logged from the WebOptimizer namespace (I checked the source on github) which should make it easy to filter out using appsettings. Just add a "WebOptimizer" key and set it to only show "Warning" and higher.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"WebOptimizer": "Warning"
}
}
}
这篇关于从内存缓存消息中删除响应信息日志级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!