I'm not sure how to use Serilog's LogContext with the CouchDB sink.
A simple example to show my current usage:
using (LogContext.PushProperty("Track", "hi"))
{
this.Log.Information("test");
}
And what I see in CouchDB Futon:
My understanding is that LogContext will add a "Track" field with the value of "hi" to all Serilog logs until it's disposed. But, I'm not seeing that happening.
(Not sure how to answer my own question, I found the solution with further research.)
In order to use the LogContext class like I was, the logger needs to be initialized with: .Enrich.FromLogContext()
I thought I had done this, but I ...didn't.
this.Log = new LoggerConfiguration()
.WriteTo.ColoredConsole()
.WriteTo.CouchDB("http://127.0.0.1:5984/logs")
.Enrich.FromLogContext()
.CreateLogger();
This is explained at: https://github.com/serilog/serilog/wiki/Enrichment
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.