Repository: serilog/serilog

Issue:
JsonFormatter RenderedMessage writes invalid output
**Description**
When using JsonFormatter with renderMessage enabled to write console output, the JSON output is not created correctly and results in invalid JSON.

**Reproduction**
1. Configure a default logger with a sinkConfiguration that uses the JsonFormatter with renderMessage = true
2. Log a message
3. The output results in invalid quoted JSON at the renderedMessage with an extra quote, for example:

`{
    "Timestamp": "2023-06-21T09:48:56.0952245+02:00",
    "Level": "Error",
    "MessageTemplate": "Testmessage with value: {TestMessageValue}"",
    "RenderedMessage": "Testmessage with value: 1",
    "Properties": {
        "TestMessageValue": "1"
    }
}`

**Expected behavior**
Using Serilog 2.12.0 the output would result in valid JSON, we would expect the same behaviour in the latest version.

**Relevant package, tooling and runtime versions**
Serilog 3.0.0

**Additional context**
Code where the extra quote is added can be found here:
https://github.com/serilog/serilog/blob/main/src/Serilog/Formatting/Json/JsonFormatter.cs#L69



Hints:

Patch:
diff --git a/src/Serilog/Formatting/Json/JsonFormatter.cs b/src/Serilog/Formatting/Json/JsonFormatter.cs
index 3ea6b3836..fab5e95e7 100644
--- a/src/Serilog/Formatting/Json/JsonFormatter.cs
+++ b/src/Serilog/Formatting/Json/JsonFormatter.cs
@@ -66,7 +66,7 @@ public void Format(LogEvent logEvent, TextWriter output)
 
         if (_renderMessage)
         {
-            output.Write("\",\"RenderedMessage\":");
+            output.Write(",\"RenderedMessage\":");
             var message = logEvent.MessageTemplate.Render(logEvent.Properties);
             JsonValueFormatter.WriteQuotedJsonString(message, output);
         }
diff --git a/src/Serilog/Serilog.csproj b/src/Serilog/Serilog.csproj
index f64a96567..438832964 100644
--- a/src/Serilog/Serilog.csproj
+++ b/src/Serilog/Serilog.csproj
@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <Description>Simple .NET logging with fully-structured events</Description>
-    <VersionPrefix>3.0.0</VersionPrefix>
+    <VersionPrefix>3.0.1</VersionPrefix>
     <Authors>Serilog Contributors</Authors>
     <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net462;net471</TargetFrameworks>
     <TargetFrameworks>$(TargetFrameworks);netstandard2.1;netstandard2.0;net5.0;net6.0;net7.0</TargetFrameworks>


Test patch:
diff --git a/test/Serilog.Tests/Formatting/Json/JsonFormatterTests.cs b/test/Serilog.Tests/Formatting/Json/JsonFormatterTests.cs
index 39c76d285..006255a34 100644
--- a/test/Serilog.Tests/Formatting/Json/JsonFormatterTests.cs
+++ b/test/Serilog.Tests/Formatting/Json/JsonFormatterTests.cs
@@ -274,4 +274,20 @@ public void SequencesOfSequencesAreSerialized()
         var h = (string)d.Properties.AProperty[0][0];
         Assert.Equal("Hello", h);
     }
+
+    [Fact] // See https://github.com/serilog/serilog/issues/1924
+    public void RenderedMessageIsIncludedCorrectlyWhenRequired()
+    {
+        var p = new MessageTemplateParser();
+        var e = new LogEvent(Some.OffsetInstant(), Information, null,
+            p.Parse("value: {AProperty}"), new[] { new LogEventProperty("AProperty", new ScalarValue(12)) });
+
+        var formatter = new JsonFormatter(renderMessage: true);
+
+        var buffer = new StringWriter();
+        formatter.Format(e, buffer);
+        var json = buffer.ToString();
+
+        Assert.Contains(@",""MessageTemplate"":""value: {AProperty}"",""RenderedMessage"":""value: 12"",", json);
+    }
 }