-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add option to not immediately emit the first log event #38
Comments
Hi! Thanks for the note. Originally, we added this behavior to reduce the incidence of support cause by programs exiting without closing/flushing the logger - getting one event through generally proves that the sink is configured correctly and leads the user to look elsewhere For subclassing some control has been desired for a while, but as this package is highly depended upon it's not easy to extend in a controlled manner. #30 has been waiting for an additional option to appear so that we can disambiguate between some constructor overloads - I'll investigate merging that PR and adding a parameter to the new, longer, constructor argument list in that PR. Thanks! |
I think most of this stems from the fact that this is a base class instead of a decorator implementation. Have you considered creating a "CompositeLogEvent" instead of exposing a new Obviously, that would probably require extracting the
Firing any methods on the composite instance would apply the operation to all events inside the composite (looking at the current interface, this appears quite doable). This would allow us to implement a batching sink that:
A decorator-based extension like that would be substantially more reusable and less coupled than a base class approach. |
Thanks for the suggestions 👍 - yes, this is a pretty old package, it's probably due for some updates along those lines. I'll take a proper look at this again :-) |
Very surprised to see this tackled so fast. Just in time for us to drop our hack to prevent the initial execution :) I left a couple comments on the merged PR in case you are interested, but the current design should already work fine for our use case. Thank you so much for the prompt resolution here. |
I was surprised when I first used my custom sink and it was being hit the first time immediately, no matter the interval I configured in the constructor.
My scenario would benefit from only running the batch after the elapsed time, even in the first time.
This code block kills this possibility:
https://github.com/serilog/serilog-sinks-periodicbatching/blob/dev/src/Serilog.Sinks.PeriodicBatching/Sinks/PeriodicBatching/PeriodicBatchingSink.cs#L238-L246
Can we at least have an option to not immediately dispatch the first event?
This behavior is really weird to me and violates the principle of least astonishment.
The text was updated successfully, but these errors were encountered: