diff --git a/src/Serilog/Debugging/SelfLog.cs b/src/Serilog/Debugging/SelfLog.cs index 86b7d775e..8580b5d16 100644 --- a/src/Serilog/Debugging/SelfLog.cs +++ b/src/Serilog/Debugging/SelfLog.cs @@ -23,6 +23,8 @@ namespace Serilog.Debugging /// public static class SelfLog { + static readonly Action _output; + /// /// The output mechanism for self-log events. /// @@ -30,7 +32,29 @@ public static class SelfLog /// SelfLog.Out = Console.Error; /// // ReSharper disable once MemberCanBePrivate.Global, UnusedAutoPropertyAccessor.Global - public static TextWriter Out { get; set; } + [Obsolete("Use SetOutput() instead")] + public static TextWriter Out + { + set + { + if (value == null) + { + SetOutput(null); + } + else + { + SetOutput(m => + { + value.WriteLine(DateTime.UtcNow.ToString("o") + " " + m); + value.Flush(); + }); + } + } + } + + public static void SetOutput(Action output) + { + } /// /// Write a message to the self-log. @@ -41,11 +65,10 @@ public static class SelfLog /// Third argument, if supplied. public static void WriteLine(string format, object arg0 = null, object arg1 = null, object arg2 = null) { - var o = Out; + var o = _output; if (o != null) { - o.WriteLine(DateTime.Now.ToString("s") + " " + format, arg0, arg1, arg2); - o.Flush(); + o(string.Format(format, arg0, arg1, arg2)); } } }