I'm actually trying to troubleshoot a problem where the SqlServer sink isn't writing anything to my database tables. I was advised to hook up the SelfLog to see what was going on but it isn't actually outputting anything and I'm not sure if I'm missing something. This is the setup method:
public SerilogLogger()
{
Serilog.Debugging.SelfLog.Enable(msg => System.Diagnostics.Trace.WriteLine(msg));
_logger = new LoggerConfiguration()
.WriteTo.MSSqlServer(@"Server=<MyConnectionString>", "Logs")
.WriteTo.Trace()
.CreateLogger();
}
The logs are being written to the output window via trace but nothing goes to the database and Serilog isn't outputting anything. I even tries deliberately messing up the connection string just to get it to output anything and no dice. Any thoughts?
Following up here in case anyone encounters the ticket; the issue was a missing call to:
Log.CloseAndFlush();
at completion of the test in which the code above was being executed.
Most helpful comment
Following up here in case anyone encounters the ticket; the issue was a missing call to:
at completion of the test in which the code above was being executed.