datalust/serilog-sinks-seq

Log flushing logic needs revisit.

firatsarlar opened this issue · 4 comments

There's something about sink's need for flushing.
You have to call Log.CloseAndFlush() to see near instant logs.
But if you combine logging with also a file log, file log start splitting -after CloseAndFlush-
Not sure is this write place about the issue but it's possible to improve flushing logic for this sink.
Thanks for all your efforts.

Thank you; this isn't the right repo for this issue, but I think your call to Log.CloseAndFlush() is misplaced. This method can/should only be called once, it's not expected that further events will be logged through the logger. It might be worthwhile going back to examine how you're calling CloseAndFlush() - it's effectively Dispose(). HTH!

I've put CloseAndFlush at ProcessExit event handler ( which checks process exit, ctrl c, domain unload ).
And clean up from other places.
But the thing that confuses me is : I've 3 sinks Console, Seq, FileLogger.
Two of them logs everything correctly, but Seq Sink misses some parts.
By the way these are all happening in MS Test runner, ( but I can see process exit messages in logs -I added that before exit process.-

To reproduce issue setup at least to sinks, console and seq. And try logging from some async tasks.
Put dispose part in exit handler.
In the end having logs in other sinks bring me back to here.

The other part of issue is Seq itself. May be this issue is about Seq.

Setting period to 100ms solved issue. Since logging use case though as continuously running apps. period arg. defaults are bigger , but in test environment app context lives 1sec. may be even less.