简体   繁体   中英

serilog minimumlevel override not working for console but does for rolling file

I have the following code which successfully only logs Information logs that exclude Microsoft and other system ones, but the console still gets some info written to it which I would like to exclude

  "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}"
    }
  }
]

},

Also here is what gets written to console but not the rolling file based on above settings

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。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM