diff --git a/src/Serilog/Formatting/Json/JsonFormatter.cs b/src/Serilog/Formatting/Json/JsonFormatter.cs index c46fa3392..83fe017d0 100644 --- a/src/Serilog/Formatting/Json/JsonFormatter.cs +++ b/src/Serilog/Formatting/Json/JsonFormatter.cs @@ -91,8 +91,8 @@ public JsonFormatter( { typeof(uint), WriteToString }, { typeof(long), WriteToString }, { typeof(ulong), WriteToString }, - { typeof(float), WriteToString }, - { typeof(double), WriteToString }, + { typeof(float), (v, q, w) => WriteSingle((float)v, w) }, + { typeof(double), (v, q, w) => WriteDouble((double)v, w) }, { typeof(decimal), WriteToString }, { typeof(string), (v, q, w) => WriteString((string)v, w) }, { typeof(DateTime), (v, q, w) => WriteDateTime((DateTime)v, w) }, @@ -382,6 +382,16 @@ static void WriteBoolean(bool value, TextWriter output) output.Write(value ? "true" : "false"); } + static void WriteSingle(float value, TextWriter output) + { + output.Write(value.ToString("R", CultureInfo.InvariantCulture)); + } + + static void WriteDouble(double value, TextWriter output) + { + output.Write(value.ToString("R", CultureInfo.InvariantCulture)); + } + static void WriteOffset(DateTimeOffset value, TextWriter output) { output.Write("\""); diff --git a/src/Serilog/Sinks/PeriodicBatching/PeriodicBatchingSink.cs b/src/Serilog/Sinks/PeriodicBatching/PeriodicBatchingSink.cs index ab44a26e7..17fb6900a 100644 --- a/src/Serilog/Sinks/PeriodicBatching/PeriodicBatchingSink.cs +++ b/src/Serilog/Sinks/PeriodicBatching/PeriodicBatchingSink.cs @@ -23,10 +23,6 @@ using Serilog.Events; using System.Threading; -#if !NO_TIMER -using System.Threading; -#endif - namespace Serilog.Sinks.PeriodicBatching { ///