Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Elastic.Serilog.Sinks - Allow flushing messages when Serilog sink is disposed #411

Closed
kudmax opened this issue Jul 10, 2024 · 2 comments · Fixed by #440
Closed
Labels
enhancement New feature or request

Comments

@kudmax
Copy link

kudmax commented Jul 10, 2024

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 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.

@kudmax kudmax added the enhancement New feature or request label Jul 10, 2024
@lowern1ght
Copy link

+1

@Mpdreamz
Copy link
Member

Thanks for highlighting this omission! This will be covered once #440 lands

Mpdreamz added a commit that referenced this issue Sep 18, 2024
…y disposing (#440)

This also updates our serology sink to implement `IDisposable` so it
waits to flush as well. See also #411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants