From 8a69d992538f4594e28f73c5bdbd6919d6eadfbb Mon Sep 17 00:00:00 2001 From: Bo Schiermer Nielsen Date: Mon, 11 Nov 2024 16:22:38 +0100 Subject: [PATCH] Extended LogEventConverter.ConvertToEcs<>() with an optional EcsDocumentCreationCache input parameter that gets passed into EcsDocument.CreateNewWithDefaults<>() This is to support overwrites of static data such as those in EcsDocument.Service --- src/Elastic.CommonSchema.Serilog/LogEventConverter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs b/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs index 14decb3d..359c8d9b 100644 --- a/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs +++ b/src/Elastic.CommonSchema.Serilog/LogEventConverter.cs @@ -21,10 +21,10 @@ public static class LogEventConverter /// /// Converts a to an /// - public static TEcsDocument ConvertToEcs(LogEvent logEvent, IEcsTextFormatterConfiguration configuration) + public static TEcsDocument ConvertToEcs(LogEvent logEvent, IEcsTextFormatterConfiguration configuration, EcsDocumentCreationCache? initialCache = null) where TEcsDocument : EcsDocument, new() { - var ecsEvent = EcsDocument.CreateNewWithDefaults(logEvent.Timestamp, logEvent.Exception, configuration); + var ecsEvent = EcsDocument.CreateNewWithDefaults(logEvent.Timestamp, logEvent.Exception, configuration, initialCache); if (logEvent.TryGetScalarString(SpecialKeys.MachineName, out var machineName)) {