Skip to content

Commit

Permalink
Merge pull request #1927 from serilog/dev
Browse files Browse the repository at this point in the history
3.0.1 Release
  • Loading branch information
nblumhardt committed Jun 21, 2023
2 parents 7c395b6 + cf2c62e commit 5e93f0d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Serilog/Formatting/Json/JsonFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog/Serilog.csproj
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
16 changes: 16 additions & 0 deletions test/Serilog.Tests/Formatting/Json/JsonFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 5e93f0d

Please sign in to comment.