I'm using Serilog and I notice when shutting down the actor system, not all outstanding log messages have been processed before custom loggers like Serilog are removed. Because of this, a bunch of messages are no longer sent to the Serilog sink and they end up in the default logger instead.
As a workaround, I use this in a ReceiveAsync
handler:
await Task.Delay(TimeSpan.FromSeconds(5));
Context.System.Terminate();
I can probably use an AutoResetEvent
or similar in a non-async handler or an FSM OnTermination
handler.
The workaround above is just that though, a workaround. Is there a way to flush the logs? Note that I already flush Serilog before shutting down the actor system, that part works fine.