diff --git a/README.md b/README.md index ee3b4fe..a1d21f7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Redbox.Serilog.Stackdriver.Tests/StackdriverFormatterTests.cs b/src/Redbox.Serilog.Stackdriver.Tests/StackdriverFormatterTests.cs index 0bc8ac1..492809c 100644 --- a/src/Redbox.Serilog.Stackdriver.Tests/StackdriverFormatterTests.cs +++ b/src/Redbox.Serilog.Stackdriver.Tests/StackdriverFormatterTests.cs @@ -91,6 +91,9 @@ private void AssertValidLogLine(Dictionary logDict, Assert.True(logDict.ContainsKey("severity")); Assert.NotEmpty(logDict["severity"]); + + Assert.True(logDict.ContainsKey(("MessageTemplate"))); + Assert.NotEmpty(logDict["MessageTemplate"]); if (hasException) { diff --git a/src/Redbox.Serilog.Stackdriver/StackdriverJsonFormatter.cs b/src/Redbox.Serilog.Stackdriver/StackdriverJsonFormatter.cs index 82442a1..3dba015 100644 --- a/src/Redbox.Serilog.Stackdriver/StackdriverJsonFormatter.cs +++ b/src/Redbox.Serilog.Stackdriver/StackdriverJsonFormatter.cs @@ -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); }