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

ConsoleSink class being internal #161

Open
megasuperlexa opened this issue Aug 16, 2024 · 1 comment
Open

ConsoleSink class being internal #161

megasuperlexa opened this issue Aug 16, 2024 · 1 comment

Comments

@megasuperlexa
Copy link

Hello, what is the reason for making the ConsoleSink class internal? I am writing my own ad-hoc limiting sink and cannot make use of ConsoleSink because it cannot be instantiated and passed inside my sink.
I have no problems with GraylogSink because it is public, so I propose to make ConsoleSync public too.

@nblumhardt
Copy link
Member

Hi! Instead of constructing the sink directly, use LoggerSinkConfiguration.Wrap(..:

var limitingSink = LoggerSinkConfiguration.Wrap(
    enclosed => new LimitingSink(enclosed),
    wt => wt.Console());

This will work with all existing Serilog sinks, and automatically handles correct IDisposable and IAsyncDisposable forwarding to the wrapped sink (removing the need to implement these on your wrapper sink type).

See also serilog/serilog#2060 - HTH!

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

2 participants