From 15e4c57d97b4e8537008f3bdccf500e2039f031e Mon Sep 17 00:00:00 2001 From: Enrico Campidoglio Date: Thu, 19 Oct 2023 11:44:17 +0200 Subject: [PATCH] Always output entire log messages (#11) This commit ensures that log messages are printed to the console's stdout in their entirety by flushing the internal buffer of the `StreamWriter` after every write operation. --- src/Serilog.Sinks.FastConsole/FastConsoleSink.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Serilog.Sinks.FastConsole/FastConsoleSink.cs b/src/Serilog.Sinks.FastConsole/FastConsoleSink.cs index 844b503..bbb9f28 100644 --- a/src/Serilog.Sinks.FastConsole/FastConsoleSink.cs +++ b/src/Serilog.Sinks.FastConsole/FastConsoleSink.cs @@ -12,7 +12,11 @@ namespace Serilog.Sinks.FastConsole; public class FastConsoleSink : ILogEventSink, IDisposable { - private static readonly StreamWriter _consoleWriter = new(Console.OpenStandardOutput(), Console.OutputEncoding, 4096, true); + private static readonly StreamWriter _consoleWriter = + new(Console.OpenStandardOutput(), Console.OutputEncoding, 4096, true) + { + AutoFlush = true + }; private readonly StringWriter _bufferWriter = new(); private readonly Channel _queue; private readonly Task _worker;