Skip to content


Repository files navigation


Nuget status

A Serilog sink wrapper to write formatted log events to a delegate.

To use the sink, install the Serilog.Sinks.DelegatingText nupkg into your solution; see below or browse to the sample sandbox code in this repository for pointers how to use it. And here is the page for Serilog.Sinks.DelegatingText.

Please note that this library is provided "as-is" and with no warranty, explicit or otherwise. You should ensure that the functionality meets your requirements, and thoroughly test them, prior to using in any production scenarios.

Use case

The Serilog.Sinks.DelegatingText sink makes it possible buffer formatted log events in your application. For more information about Serilog, see and

private readonly StringBuilder  _logEventBuffer = new StringBuilder();

private void ConfigureApp()
    Log.Logger = new LoggerConfiguration()
        // Using a delegate to buffer log messages
        .WriteTo.DelegatingTextSink(w => WriteToBuffer(w), outputTemplate:"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")

    Log.Information("Hello from the sandbox");
    Log.Warning("Sample warning");
    Log.Error("Sample error");
    Log.Error(new Exception("A sample exception"), "Sample error with exception");

    // ...

private void WriteToBuffer(string formattedLogMessage)

private void SomeFunction()
    // do something with the buffered log events


A Serilog sink to emit formatted log events to a delegate.






No packages published