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". 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) {