From 8ee8fac7a6f740879753c8af6798ea78af693f02 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 18 Oct 2022 14:09:55 -0700 Subject: [PATCH] ConsoleLogExporter to output full exception --- src/OpenTelemetry.Exporter.Console/CHANGELOG.md | 4 ++++ .../ConsoleLogRecordExporter.cs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md index 1c94054370c..e8cbcd2316a 100644 --- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +LogRecordExporter to print full exception details instead of just Message, when +using `ILogger` to log exception. +([#3784](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3784)) + ## 1.4.0-beta.2 Released 2022-Oct-17 diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs index 811838e20c0..45f5a5ca545 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using OpenTelemetry.Internal; using OpenTelemetry.Logs; using OpenTelemetry.Resources; @@ -137,7 +138,7 @@ public override ExportResult Export(in Batch batch) if (logRecord.Exception != null) { - this.WriteLine($"{"LogRecord.Exception:",-RightPaddingLength}{logRecord.Exception?.Message}"); + this.WriteLine($"{"LogRecord.Exception:",-RightPaddingLength}{logRecord.Exception.ToInvariantString()}"); } int scopeDepth = -1;