在我的Blazor WebAssembly客户端中,我具有以下设置:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
}
}
那为什么在本地运行时为什么我的浏览器控制台仍然无休止呢?
info: System.Net.Http.HttpClient.MyNamedClientName.ClientHandler[101]
Received HTTP response headers after 190ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.LogicalHandler[101]
End processing HTTP request after 193ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.ClientHandler[101]
Received HTTP response headers after 267ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.LogicalHandler[101]
End processing HTTP request after 274ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.ClientHandler[101]
Received HTTP response headers after 316ms - 200 blazor.webassembly.js:1:9737
info: System.Net.Http.HttpClient.MyNamedClientName.LogicalHandler[101]
End processing HTTP request after 319ms - 200
如何关闭这些信息行?
答案 0 :(得分:2)
在 .NET 5 最新版本中,如果您不想在 blazor 客户端显示这些内容,您可以在启动类的 Main 方法中执行此操作。
builder.Logging.SetMinimumLevel(LogLevel.None);
答案 1 :(得分:1)
using Microsoft.Extensions.Logging;
...
builder.Logging.AddConfiguration(
builder.Configuration.GetSection("Logging"));
您必须在构建器中配置记录器。