![](/img/trans.png)
[英]What does MinimumLevel and Override mean in appsettings.json logging context?
[英]serilog minimumlevel override not working for console but does for rolling file
我有以下代碼,該代碼僅成功記錄了不包括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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.