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

Catch block in EmitBatchAsync() prevents fallback sinks from running #83

Open
nblumhardt opened this issue Feb 26, 2025 · 0 comments
Open

Comments

@nblumhardt
Copy link
Contributor

Howdy! :-)

Serilog now supports failure listeners natively, which among other things, allows failed batches to be rerouted to an alternative sink:

https://nblumhardt.com/2024/10/fallback-logging/

Unfortunately, this doesn't quite work with the PostgreSQL sink, because exceptions are suppressed after invoking the failureCallback.

https://github.com/serilog-contrib/Serilog.Sinks.Postgresql.Alternative/blob/master/src/Serilog.Sinks.Postgresql.Alternative/Sinks/PostgreSQL/PostgreSQLSink.cs#L54

I'd suggest deprecating failureCallback, and changing the implementation to:

        catch (Exception ex)
        {
            this.sinkHelper.SinkOptions.FailureCallback?.Invoke(ex);
            throw;
        }

The Serilog infrastructure also handles SelfLog so this can be dropped.

Let me know if you'd like a PR along these lines. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant