From 0612057f76c30e09f7a61272aef5c3b82885b7d9 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Sun, 1 Dec 2024 11:21:17 +0000 Subject: [PATCH] Dispose the StringWriter created in Emit() --- src/Serilog.Sinks.Trace/Sinks/Trace/TraceSink.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Serilog.Sinks.Trace/Sinks/Trace/TraceSink.cs b/src/Serilog.Sinks.Trace/Sinks/Trace/TraceSink.cs index 8dfa960..2ac8862 100644 --- a/src/Serilog.Sinks.Trace/Sinks/Trace/TraceSink.cs +++ b/src/Serilog.Sinks.Trace/Sinks/Trace/TraceSink.cs @@ -32,7 +32,7 @@ public TraceSink(ITextFormatter textFormatter) public void Emit(LogEvent logEvent) { if (logEvent == null) throw new ArgumentNullException(nameof(logEvent)); - var sr = new StringWriter(); + using var sr = new StringWriter(); _textFormatter.Format(logEvent, sr); var text = sr.ToString().Trim();