diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs index 2e3731e1d3b..c35cf543222 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs @@ -42,7 +42,11 @@ public override ExportResult Export(in Batch batch) this.WriteLine($"{"LogRecord.TraceFlags:",-RightPaddingLength}{logRecord.TraceFlags}"); } - this.WriteLine($"{"LogRecord.CategoryName:",-RightPaddingLength}{logRecord.CategoryName}"); + if (logRecord.CategoryName != null) + { + this.WriteLine($"{"LogRecord.CategoryName:",-RightPaddingLength}{logRecord.CategoryName}"); + } + this.WriteLine($"{"LogRecord.LogLevel:",-RightPaddingLength}{logRecord.LogLevel}"); if (logRecord.FormattedMessage != null) @@ -76,13 +80,13 @@ public override ExportResult Export(in Batch batch) if (logRecord.EventId != default) { this.WriteLine($"{"LogRecord.EventId:",-RightPaddingLength}{logRecord.EventId.Id}"); - if (string.IsNullOrEmpty(logRecord.EventId.Name)) + if (!string.IsNullOrEmpty(logRecord.EventId.Name)) { this.WriteLine($"{"LogRecord.EventName:",-RightPaddingLength}{logRecord.EventId.Name}"); } } - if (logRecord.Exception is { }) + if (logRecord.Exception != null) { this.WriteLine($"{"LogRecord.Exception:",-RightPaddingLength}{logRecord.Exception?.Message}"); }