Reputation: 620
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.
Upvotes: 1
Views: 297
Reputation: 620
(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
Upvotes: 2