I have a Windows Service that processes long running tasks and never shuts down unless forcefully done so (i.e. computer shutdown). I would like to keep the same Serilog instance alive the whole time Windows service is up and running (for performance reason).
However, I only see logs after the Dispose() call as shown below.
var logger = new LoggerConfiguration()
.WriteTo.Seq("http://localhost:5341")
.CreateLogger();
logger.ForContext("TestContext", new { Machine = "TSTDB2" }, true).Information("Test");
logger.Dispose();
I would not mind a few seconds delay but having to wait until the Serilog instance is disposed does not work for me. Any solutions would be greatly appreciated.
Program.csreproduction? Are you creating more than one logger instance, or assigning the logger to a static field somewhere? (HTH, just trying to generate ideas.) - Nicholas Blumhardt