From fe3c4a739694e345aa29e413c162b66f7da67ea1 Mon Sep 17 00:00:00 2001 From: Martin Rapavy Date: Thu, 1 Feb 2024 17:17:06 -0600 Subject: [PATCH] Added AssemblyName to Tags --- src/SerilogEcsLogging/Logging/EcsMapper.cs | 7 +++++++ src/SerilogEcsLogging/SerilogEcsLogging.csproj | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SerilogEcsLogging/Logging/EcsMapper.cs b/src/SerilogEcsLogging/Logging/EcsMapper.cs index 0a4aad9..2a7476b 100644 --- a/src/SerilogEcsLogging/Logging/EcsMapper.cs +++ b/src/SerilogEcsLogging/Logging/EcsMapper.cs @@ -20,6 +20,13 @@ public static Elastic.CommonSchema.EcsDocument MapLogEvent(Elastic.CommonSchema. string[] tagsStrings = Array.ConvertAll(tags, o => o.ToString()).Where(t => t != null).ToArray()!; result.Tags = result.Tags != null ? result.Tags.Concat(tagsStrings).ToArray() : tagsStrings; } + + // Add AssemblyName to Tags + if (logEvent.Properties.TryGetValue("AssemblyName", out var assemblyName) && assemblyName is ScalarValue) + { + var serviceName = assemblyName.ToString().Trim('"'); + result.Tags = result.Tags != null ? result.Tags.Concat(new[] { serviceName }).ToArray() : new[] { serviceName }; + } if (result.Tags != null) { diff --git a/src/SerilogEcsLogging/SerilogEcsLogging.csproj b/src/SerilogEcsLogging/SerilogEcsLogging.csproj index 91c74d3..7278567 100644 --- a/src/SerilogEcsLogging/SerilogEcsLogging.csproj +++ b/src/SerilogEcsLogging/SerilogEcsLogging.csproj @@ -7,7 +7,7 @@ true mrapavy https://github.com/mrapavy/serilog-ecs-logging - 1.1.5 + 1.1.6