From 9fcbba85b944ec013b2a644e21a929bef8c83fc4 Mon Sep 17 00:00:00 2001 From: Georgios Chondrompilas Date: Tue, 2 Feb 2021 09:31:33 +0100 Subject: [PATCH 1/2] fix(exception-logging): Added Exception.ToString() to NewRelicLogItem More information about the Exception will be included in the log entry (inner exceptions, message, exception type) --- .../Sinks/NewRelicLogs/NewRelicLogPayload.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Serilog.Sinks.NewRelic.Logs/Sinks/NewRelicLogs/NewRelicLogPayload.cs b/src/Serilog.Sinks.NewRelic.Logs/Sinks/NewRelicLogs/NewRelicLogPayload.cs index 2b0a09f..c942b08 100644 --- a/src/Serilog.Sinks.NewRelic.Logs/Sinks/NewRelicLogs/NewRelicLogPayload.cs +++ b/src/Serilog.Sinks.NewRelic.Logs/Sinks/NewRelicLogs/NewRelicLogPayload.cs @@ -40,6 +40,10 @@ public NewRelicLogItem(LogEvent logEvent, IFormatProvider formatProvider) this.Message = logEvent.RenderMessage(formatProvider); this.Attributes.Add("level", logEvent.Level.ToString()); this.Attributes.Add("stack_trace", logEvent.Exception?.StackTrace ?? ""); + if (logEvent.Exception != null) + { + this.Attributes.Add("exception", logEvent.Exception.ToString() ?? ""); + } foreach (var property in logEvent.Properties) { From 5853fbb2e5ec1ab9cbfd5695b234dea136d78de7 Mon Sep 17 00:00:00 2001 From: Georgios Chondrompilas Date: Tue, 2 Feb 2021 10:14:06 +0100 Subject: [PATCH 2/2] chore(docs): Updates README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8469e2c..e479997 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ This sink adds four additional properties: * `application` holds the value from `applicationName` * `level` is the actual log level of the event. * `stack_trace` holds the stack trace portion of an exception. +* `exception` holds the `.toString()` of an exception. If `newrelic.linkingmetadata` property is present in an event, it will be unrolled into individual NewRelic properties used for "logs in context".