![](/img/trans.png)
[英]Serilog File Sink - System.MissingMethodException: Method not found: Serilog.LoggerConfiguration
[英]Serilog LoggerConfiguration write to different Sink by context
我有使用IdentityServer3
web asp.net MVC應用程序。 我想將日志記錄拆分到其他接收器。 我想將IdentityServer3
Trace
, EventLog("IdentityServer3")
和SerilogWeb.Classic.Enrichers
到數據庫MSSqlServer
。
我的配置是:
Log.Logger = new LoggerConfiguration()
.WriteTo.Trace()
.WriteTo.EventLog("IdentityServer3")
.Enrich.FromLogContext()
//all after this i want to write in database
.WriteTo.MSSqlServer("connectionString", "Log")
.Enrich.With(new HttpRequestIdEnricher())
.Enrich.With(new HttpRequestRawUrlEnricher())
.Enrich.With(new HttpRequestUserAgentEnricher())
.Enrich.With(new UserNameEnricher())
.CreateLogger();
要將事件的子集寫入接收器,請使用WriteTo.Logger()
和Filter
指令。 每種情況都是相似的; 這是身份服務器之一:
Log.Logger = new LoggerConfiguration()
.WriteTo.Logger(lc => lc
.Filter.ByIncludingOnly(Matching.FromSource("IdentityServer3"))
.WriteTo.Trace()
.WriteTo.EventLog("IdentityServer3"))
// <snip>
您可以在最外層應用擴展程序,以便它們豐富所有事件,也可以在嵌套的記錄器配置之一上應用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.