Skip to content

Commit

Permalink
Made MessageTemplate capitalized to match Serilog defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Lin Meyer authored and jvasallo committed Jun 15, 2020
1 parent 0ea08c5 commit 372a622
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Stackdriver will break the long line into multiple lines, which will break searc

#### includeMessageTemplate

Default `true`. If the Serilog Message Template should be included in the logs, e.g. ` { ... "messageTemplate" : "Hello from {name:l}" ... }`
Default `true`. If the Serilog Message Template should be included in the logs, e.g. ` { ... "MessageTemplate" : "Hello from {name:l}" ... }`

#### valueFormatter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ private void AssertValidLogLine(Dictionary<string, string> logDict,

Assert.True(logDict.ContainsKey("severity"));
Assert.NotEmpty(logDict["severity"]);

Assert.True(logDict.ContainsKey(("MessageTemplate")));
Assert.NotEmpty(logDict["MessageTemplate"]);

if (hasException)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Redbox.Serilog.Stackdriver/StackdriverJsonFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public void FormatEvent(LogEvent logEvent, TextWriter originalOutput, JsonValueF
// Serilog Message Template
if (_includeMessageTemplate)
{
output.Write(",\"messageTemplate\":");
// Capitalized to match default Serilog JsonFormatter
output.Write(",\"MessageTemplate\":");
JsonValueFormatter.WriteQuotedJsonString(logEvent.MessageTemplate.Text, output);
}

Expand Down

0 comments on commit 372a622

Please sign in to comment.