我有以下代码,它成功地只记录了排除 Microsoft 和其他系统日志的信息日志,但控制台仍然会写入一些我想排除的信息
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": { "outputTemplate": "[{Timestamp:HH:mm:ss.fff}] {Level:u3} - {Message}{NewLine}{Exception}" }
},
{
"Name": "RollingFile",
"Args": {
"pathFormat": "log-{Date}.log",
"outputTemplate": "[{Timestamp:dd/MM/yy HH:mm:ss.fff z}] {Level:u3} {Message}{NewLine}{Exception}"
}
}
]
},
这里也是写入控制台的内容,而不是基于上述设置的滚动文件
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 2.0.1-rtm-125 initialized 'CryptoAlertContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: None
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
Executed DbCommand (26ms) [Parameters=[@__p_0='?'], CommandType='Text', CommandTimeout='30']
SELECT TOP(@__p_0) [x].[CoinId], [x].[Icon], [x].[LastPriceBtc], [x].[LastPriceUsd], [x].[LastUpdated], [x].[Name], [x].[Rank], [x].[Symbol]
FROM [Coins] AS [x]
ORDER BY [x].[Rank]
看起来UseSerilog()
您的程序启动代码中缺少:您显示的控制台输出来自默认的 ASP.NET 日志记录提供程序,而不是 Serilog 提供程序。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句