Closed samdevx1029 closed 6 years ago
Hi, thanks for the report. Could you please include the SelfLog
output? Thanks!
Sure, here is the output.
2017-10-04T01:57:50.4549728Z Exception while emitting periodic batch from Serilog.Sinks.Seq.SeqSink: System.Threading.ThreadAbortException: Thread was being aborted.
at Serilog.Sinks.Seq.SeqSink.
Hi Sam, thanks for the additional info.
The problem is that logging to Seq happens asynchronously; the unit test framework is terminating the process before the logs have been sent.
You don't see the issue in your other unit test because you're Dispose()
ing the logger, there.
Serilog's own static logger has a method CloseAndFlush()
to dispose the logger before program exit; you could add the same to your Singleton
class and call it from the unit test to get the same result.
HTH!
Closing with the expectation that the info above will be enough to unblock you, but please get in touch if you need further help. Cheers!
I am having a strange issue using a singleton instance that wraps a Serilog logger configured with SEQ. Nothing gets written to SEQ. If I replace SEQ with a rolling file, log is written. Enabling the self log revealed there is a problem only when using SEQ.
To reproduce this error, see the unit test named Serilog_Singleton_TestError() in the attached VS2017 unit test project. UnitTestProject1.zip
In summary, follow these steps
I added another unit test named Serilog_TestError() that does not use singleton. This time SEQ works. I hope this has nothing to do with the way I wrote singleton. You can try your way. I think the problem is related to System.Net.Http and SEQ I saw in other blog posts.
Any help would be greatly appreciated.