Is your feature request related to a problem? Please describe.
If the application shuts down without suitable timeout, all logged messages waiting in the internal buffer will be lost. Unfortunately, there are no flushing capabilities available to process the internal buffer before its OutboundBufferMaxLifetime expires or the maximum number of elements is reached.
Describe the solution you'd like
The Serilog static API includes a CloseAndFlush() method that finalizes the underlying configured logger. When invoked, this method disposes the logger, which in turn disposes of all its sinks. If the sink needs to complete logging in a specific way (such as flushing messages temporarily residing in the internal buffer), it should implement IDisposable or IAsyncDisposable.
Considering this, I would propose supplying the Elasticsearch sink with IDisposable implementation that would ensure proper flushing in the hosted channel at dispose, preventing the loss of buffered messages.
ECS integration/library project(s):
Elastic.Serilog.Sinks
Is your feature request related to a problem? Please describe. If the application shuts down without suitable timeout, all logged messages waiting in the internal buffer will be lost. Unfortunately, there are no flushing capabilities available to process the internal buffer before its
OutboundBufferMaxLifetime
expires or the maximum number of elements is reached.Describe the solution you'd like The
Serilog
static API includes aCloseAndFlush()
method that finalizes the underlying configured logger. When invoked, this method disposes the logger, which in turn disposes of all its sinks. If the sink needs to complete logging in a specific way (such as flushing messages temporarily residing in the internal buffer), it should implementIDisposable
orIAsyncDisposable
.Considering this, I would propose supplying the Elasticsearch sink with IDisposable implementation that would ensure proper flushing in the hosted channel at dispose, preventing the loss of buffered messages.