From 7ec53428c3d2569d803841dd7480787f7c83ca9a Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 12 Jun 2024 15:21:14 -0700 Subject: [PATCH 1/4] Add trace correlation fields to Microsoft.Extensions.Logging.EventSource. --- .../src/EventSourceLogger.cs | 57 +++++- .../src/LoggingEventSource.cs | 167 ++++++++++++------ .../tests/EventSourceLoggerTest.cs | 69 +++++++- 3 files changed, 224 insertions(+), 69 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs index b2ad0238529a1..d029368d0af39 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs @@ -4,6 +4,7 @@ using System; using System.Buffers; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.Tracing; using System.IO; using System.Text; @@ -57,23 +58,58 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except { return; } + + bool formattedMessageEventEnabled = _eventSource.IsEnabled(EventLevel.Critical, LoggingEventSource.Keywords.FormattedMessage); + bool messageEventEnabled = _eventSource.IsEnabled(EventLevel.Critical, LoggingEventSource.Keywords.Message); + bool jsonMessageEventEnabled = _eventSource.IsEnabled(EventLevel.Critical, LoggingEventSource.Keywords.JsonMessage); + + if (!formattedMessageEventEnabled + && !messageEventEnabled + && !jsonMessageEventEnabled) + { + return; + } + string? message = null; + Activity? activity = Activity.Current; + string? activityTraceId; + string? activitySpanId; + string? activityTraceFlags; + if (activity != null && activity.IdFormat == ActivityIdFormat.W3C) + { + activityTraceId = activity.TraceId.ToHexString(); + activitySpanId = activity.SpanId.ToHexString(); + activityTraceFlags = activity.ActivityTraceFlags == ActivityTraceFlags.None + ? "0" + : "1"; + } + else + { + activityTraceId = null; + activitySpanId = null; + activityTraceFlags = null; + } + // See if they want the formatted message - if (_eventSource.IsEnabled(EventLevel.Critical, LoggingEventSource.Keywords.FormattedMessage)) + if (formattedMessageEventEnabled) { message = formatter(state, exception); + _eventSource.FormattedMessage( logLevel, _factoryID, CategoryName, eventId.Id, eventId.Name, - message); + message, + activityTraceId, + activitySpanId, + activityTraceFlags); } // See if they want the message as its component parts. - if (_eventSource.IsEnabled(EventLevel.Critical, LoggingEventSource.Keywords.Message)) + if (messageEventEnabled) { ExceptionInfo exceptionInfo = GetExceptionInfo(exception); IReadOnlyList> arguments = GetProperties(state); @@ -85,11 +121,14 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except eventId.Id, eventId.Name, exceptionInfo, - arguments); + arguments, + activityTraceId, + activitySpanId, + activityTraceFlags); } // See if they want the json message - if (_eventSource.IsEnabled(EventLevel.Critical, LoggingEventSource.Keywords.JsonMessage)) + if (jsonMessageEventEnabled) { string exceptionJson = "{}"; if (exception != null) @@ -104,8 +143,9 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except }; exceptionJson = ToJson(exceptionInfoData); } + IReadOnlyList> arguments = GetProperties(state); - message ??= formatter(state, exception); + _eventSource.MessageJson( logLevel, _factoryID, @@ -114,7 +154,10 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except eventId.Name, exceptionJson, ToJson(arguments), - message); + message ?? formatter(state, exception), + activityTraceId, + activitySpanId, + activityTraceFlags); } } diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs index fb2705c80319b..847cc6089f8c8 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs @@ -128,33 +128,49 @@ private LoggingEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFo /// FormattedMessage() is called when ILogger.Log() is called. and the FormattedMessage keyword is active /// This only gives you the human readable formatted message. /// - [Event(1, Keywords = Keywords.FormattedMessage, Level = EventLevel.LogAlways)] + [Event(1, Keywords = Keywords.FormattedMessage, Level = EventLevel.LogAlways, Version = 2)] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = WriteEventCoreSuppressionJustification)] - internal unsafe void FormattedMessage(LogLevel Level, int FactoryID, string LoggerName, int EventId, string? EventName, string FormattedMessage) + internal unsafe void FormattedMessage( + LogLevel Level, + int FactoryID, + string LoggerName, + int EventId, + string? EventName, + string? FormattedMessage, + string? ActivityTraceId, + string? ActivitySpanId, + string? ActivityTraceFlags) { - if (IsEnabled()) + Debug.Assert(LoggerName != null); + + EventName ??= string.Empty; + FormattedMessage ??= string.Empty; + ActivityTraceId ??= string.Empty; + ActivitySpanId ??= string.Empty; + ActivityTraceFlags ??= string.Empty; + + fixed (char* loggerName = LoggerName) + fixed (char* eventName = EventName) + fixed (char* formattedMessage = FormattedMessage) + fixed (char* activityTraceId = ActivityTraceId) + fixed (char* activitySpanId = ActivitySpanId) + fixed (char* activityTraceFlags = ActivityTraceFlags) { - LoggerName ??= ""; - EventName ??= ""; - FormattedMessage ??= ""; - - fixed (char* loggerName = LoggerName) - fixed (char* eventName = EventName) - fixed (char* formattedMessage = FormattedMessage) - { - const int eventDataCount = 6; - EventData* eventData = stackalloc EventData[eventDataCount]; - - SetEventData(ref eventData[0], ref Level); - SetEventData(ref eventData[1], ref FactoryID); - SetEventData(ref eventData[2], ref LoggerName, loggerName); - SetEventData(ref eventData[3], ref EventId); - SetEventData(ref eventData[4], ref EventName, eventName); - SetEventData(ref eventData[5], ref FormattedMessage, formattedMessage); - - WriteEventCore(1, eventDataCount, eventData); - } + const int eventDataCount = 9; + EventData* eventData = stackalloc EventData[eventDataCount]; + + SetEventData(ref eventData[0], ref Level); + SetEventData(ref eventData[1], ref FactoryID); + SetEventData(ref eventData[2], ref LoggerName, loggerName); + SetEventData(ref eventData[3], ref EventId); + SetEventData(ref eventData[4], ref EventName, eventName); + SetEventData(ref eventData[5], ref FormattedMessage, formattedMessage); + SetEventData(ref eventData[6], ref ActivityTraceId, activityTraceId); + SetEventData(ref eventData[7], ref ActivitySpanId, activitySpanId); + SetEventData(ref eventData[8], ref ActivityTraceFlags, activityTraceFlags); + + WriteEventCore(1, eventDataCount, eventData); } } @@ -162,16 +178,31 @@ internal unsafe void FormattedMessage(LogLevel Level, int FactoryID, string Logg /// Message() is called when ILogger.Log() is called. and the Message keyword is active /// This gives you the logged information in a programmatic format (arguments are key-value pairs) /// - [Event(2, Keywords = Keywords.Message, Level = EventLevel.LogAlways)] + [Event(2, Keywords = Keywords.Message, Level = EventLevel.LogAlways, Version = 2)] [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(KeyValuePair))] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = WriteEventDynamicDependencySuppressionJustification)] - internal void Message(LogLevel Level, int FactoryID, string LoggerName, int EventId, string? EventName, ExceptionInfo Exception, IEnumerable> Arguments) + internal void Message( + LogLevel Level, + int FactoryID, + string LoggerName, + int EventId, + string? EventName, + ExceptionInfo Exception, + IEnumerable> Arguments, + string? ActivityTraceId, + string? ActivitySpanId, + string? ActivityTraceFlags) { - if (IsEnabled()) - { - WriteEvent(2, Level, FactoryID, LoggerName, EventId, EventName, Exception, Arguments); - } + Debug.Assert(LoggerName != null); + Debug.Assert(Exception != null); + + EventName ??= string.Empty; + ActivityTraceId ??= string.Empty; + ActivitySpanId ??= string.Empty; + ActivityTraceFlags ??= string.Empty; + + WriteEvent(2, Level, FactoryID, LoggerName, EventId, EventName, Exception, Arguments, ActivityTraceId, ActivitySpanId, ActivityTraceFlags); } /// @@ -212,39 +243,57 @@ internal unsafe void ActivityStop(int ID, int FactoryID, string LoggerName) } } - [Event(5, Keywords = Keywords.JsonMessage, Level = EventLevel.LogAlways)] + [Event(5, Keywords = Keywords.JsonMessage, Level = EventLevel.LogAlways, Version = 2)] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = WriteEventCoreSuppressionJustification)] - internal unsafe void MessageJson(LogLevel Level, int FactoryID, string LoggerName, int EventId, string? EventName, string ExceptionJson, string ArgumentsJson, string FormattedMessage) + internal unsafe void MessageJson( + LogLevel Level, + int FactoryID, + string LoggerName, + int EventId, + string? EventName, + string ExceptionJson, + string ArgumentsJson, + string? FormattedMessage, + string? ActivityTraceId, + string? ActivitySpanId, + string? ActivityTraceFlags) { - if (IsEnabled()) + Debug.Assert(LoggerName != null); + Debug.Assert(ExceptionJson != null); + Debug.Assert(ArgumentsJson != null); + + EventName ??= string.Empty; + FormattedMessage ??= string.Empty; + ActivityTraceId ??= string.Empty; + ActivitySpanId ??= string.Empty; + ActivityTraceFlags ??= string.Empty; + + fixed (char* loggerName = LoggerName) + fixed (char* eventName = EventName) + fixed (char* exceptionJson = ExceptionJson) + fixed (char* argumentsJson = ArgumentsJson) + fixed (char* formattedMessage = FormattedMessage) + fixed (char* activityTraceId = ActivityTraceId) + fixed (char* activitySpanId = ActivitySpanId) + fixed (char* activityTraceFlags = ActivityTraceFlags) { - LoggerName ??= ""; - EventName ??= ""; - ExceptionJson ??= ""; - ArgumentsJson ??= ""; - FormattedMessage ??= ""; - - fixed (char* loggerName = LoggerName) - fixed (char* eventName = EventName) - fixed (char* exceptionJson = ExceptionJson) - fixed (char* argumentsJson = ArgumentsJson) - fixed (char* formattedMessage = FormattedMessage) - { - const int eventDataCount = 8; - EventData* eventData = stackalloc EventData[eventDataCount]; - - SetEventData(ref eventData[0], ref Level); - SetEventData(ref eventData[1], ref FactoryID); - SetEventData(ref eventData[2], ref LoggerName, loggerName); - SetEventData(ref eventData[3], ref EventId); - SetEventData(ref eventData[4], ref EventName, eventName); - SetEventData(ref eventData[5], ref ExceptionJson, exceptionJson); - SetEventData(ref eventData[6], ref ArgumentsJson, argumentsJson); - SetEventData(ref eventData[7], ref FormattedMessage, formattedMessage); - - WriteEventCore(5, eventDataCount, eventData); - } + const int eventDataCount = 11; + EventData* eventData = stackalloc EventData[eventDataCount]; + + SetEventData(ref eventData[0], ref Level); + SetEventData(ref eventData[1], ref FactoryID); + SetEventData(ref eventData[2], ref LoggerName, loggerName); + SetEventData(ref eventData[3], ref EventId); + SetEventData(ref eventData[4], ref EventName, eventName); + SetEventData(ref eventData[5], ref ExceptionJson, exceptionJson); + SetEventData(ref eventData[6], ref ArgumentsJson, argumentsJson); + SetEventData(ref eventData[7], ref FormattedMessage, formattedMessage); + SetEventData(ref eventData[8], ref ActivityTraceId, activityTraceId); + SetEventData(ref eventData[9], ref ActivitySpanId, activitySpanId); + SetEventData(ref eventData[10], ref ActivityTraceFlags, activityTraceFlags); + + WriteEventCore(5, eventDataCount, eventData); } } @@ -505,6 +554,8 @@ private static unsafe void SetEventData(ref EventData eventData, ref T value, { string str = (value as string)!; #if DEBUG + Debug.Assert(str != null); + fixed (char* rePinnedString = str) { Debug.Assert(pinnedString == rePinnedString); diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs index 343036cca5b5c..6727029755f8a 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.Tracing; using System.Globalization; using System.IO; @@ -10,7 +11,6 @@ using System.Text.Json; using Microsoft.Extensions.Logging.EventSource; using Xunit; -using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; namespace Microsoft.Extensions.Logging.Test @@ -135,7 +135,7 @@ public void FilterSpecs_IncreaseLoggingLevelForOneCategory_DisablesExistingRules var logger2 = loggerFactory.CreateLogger("Logger2"); var logger3 = loggerFactory.CreateLogger("Logger3"); var logger4 = loggerFactory.CreateLogger("Logger4"); - + foreach (LogLevel level in Enum.GetValues(typeof(LogLevel))) { Assert.False(logger.IsEnabled(LogLevel.None)); @@ -195,6 +195,67 @@ public void Logs_AsExpected_WithDefaults() } } + [Theory] + [InlineData(true, true, true)] + [InlineData(true, true, false)] + [InlineData(true, false, true)] + [InlineData(false, true, true)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/73438", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] + public void Logs_TracingDetailsAsExpected_WithDefaults(bool hasTrace, bool useW3CFormatId, bool sampled) + { + using (var testListener = new TestEventListener()) + { + var factory = CreateLoggerFactory(); + + var listenerSettings = new TestEventListener.ListenerSettings(); + listenerSettings.Keywords = (EventKeywords)(-1); + listenerSettings.FilterSpec = null; + listenerSettings.Level = default(EventLevel); + testListener.EnableEvents(listenerSettings); + + using Activity activity = new Activity("TestOperation"); + + if (useW3CFormatId) + { + activity.SetIdFormat(ActivityIdFormat.W3C); + } + else + { + activity.SetIdFormat(ActivityIdFormat.Hierarchical); + } + + if (hasTrace) + { + activity.Start(); + } + + if (sampled) + { + activity.ActivityTraceFlags = ActivityTraceFlags.Recorded; + } + + var logger = factory.CreateLogger("TestLogger"); + + logger.LogInformation("Hello world"); + + foreach (var eventJson in testListener.Events) + { + if (hasTrace && useW3CFormatId) + { + Assert.Contains($@"""ActivityTraceId"":""{activity.TraceId.ToHexString()}""", eventJson); + Assert.Contains($@"""ActivitySpanId"":""{activity.SpanId.ToHexString()}""", eventJson); + Assert.Contains($@"""ActivityTraceFlags"":""{(activity.Recorded ? "1" : "0")}""", eventJson); + } + else + { + Assert.Contains(@"""ActivityTraceId"":""""", eventJson); + Assert.Contains(@"""ActivitySpanId"":""""", eventJson); + Assert.Contains(@"""ActivityTraceFlags"":""""", eventJson); + } + } + } + } + [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/73438", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public void Logs_AsExpected_WithDefaults_EnabledEarly() @@ -588,7 +649,7 @@ public void Logs_AsExpected_MessageJson_WithNullString() // Write some MessageJson events with null string. for (var i = 0; i < 100; i++) { - LoggingEventSource.Instance.MessageJson(LogLevel.Trace, 1, "MyLogger", 5, null, null, "testJson", "formattedMessage"); + LoggingEventSource.Instance.MessageJson(LogLevel.Trace, 1, "MyLogger", 5, null, "testJson", "testJson", "formattedMessage", null, null, null); } bool containsNullEventName = false; @@ -605,7 +666,7 @@ public void Logs_AsExpected_MessageJson_WithNullString() } } - Assert.True(containsNullEventName, "EventName and ExceptionJson is supposed to be null but it isn't."); + Assert.True(containsNullEventName, "EventName is supposed to be null but it isn't."); Assert.True(containsFormattedMessage, "FormattedMessage is supposed to be present but it isn't."); } } From e68e9a5677b6a6d37092932723803e0971108de7 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 18 Jun 2024 11:47:36 -0700 Subject: [PATCH 2/4] Code review. --- .../src/EventSourceLogger.cs | 12 +++---- .../src/LoggingEventSource.cs | 36 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs index d029368d0af39..0bfc67c2ef99c 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/EventSourceLogger.cs @@ -73,9 +73,9 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except string? message = null; Activity? activity = Activity.Current; - string? activityTraceId; - string? activitySpanId; - string? activityTraceFlags; + string activityTraceId; + string activitySpanId; + string activityTraceFlags; if (activity != null && activity.IdFormat == ActivityIdFormat.W3C) { activityTraceId = activity.TraceId.ToHexString(); @@ -86,9 +86,9 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except } else { - activityTraceId = null; - activitySpanId = null; - activityTraceFlags = null; + activityTraceId = string.Empty; + activitySpanId = string.Empty; + activityTraceFlags = string.Empty; } // See if they want the formatted message diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs index 847cc6089f8c8..66a95042e84cf 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/src/LoggingEventSource.cs @@ -138,17 +138,17 @@ internal unsafe void FormattedMessage( int EventId, string? EventName, string? FormattedMessage, - string? ActivityTraceId, - string? ActivitySpanId, - string? ActivityTraceFlags) + string ActivityTraceId, + string ActivitySpanId, + string ActivityTraceFlags) { Debug.Assert(LoggerName != null); + Debug.Assert(ActivityTraceId != null); + Debug.Assert(ActivitySpanId != null); + Debug.Assert(ActivityTraceFlags != null); EventName ??= string.Empty; FormattedMessage ??= string.Empty; - ActivityTraceId ??= string.Empty; - ActivitySpanId ??= string.Empty; - ActivityTraceFlags ??= string.Empty; fixed (char* loggerName = LoggerName) fixed (char* eventName = EventName) @@ -190,17 +190,17 @@ internal void Message( string? EventName, ExceptionInfo Exception, IEnumerable> Arguments, - string? ActivityTraceId, - string? ActivitySpanId, - string? ActivityTraceFlags) + string ActivityTraceId, + string ActivitySpanId, + string ActivityTraceFlags) { Debug.Assert(LoggerName != null); Debug.Assert(Exception != null); + Debug.Assert(ActivityTraceId != null); + Debug.Assert(ActivitySpanId != null); + Debug.Assert(ActivityTraceFlags != null); EventName ??= string.Empty; - ActivityTraceId ??= string.Empty; - ActivitySpanId ??= string.Empty; - ActivityTraceFlags ??= string.Empty; WriteEvent(2, Level, FactoryID, LoggerName, EventId, EventName, Exception, Arguments, ActivityTraceId, ActivitySpanId, ActivityTraceFlags); } @@ -255,19 +255,19 @@ internal unsafe void MessageJson( string ExceptionJson, string ArgumentsJson, string? FormattedMessage, - string? ActivityTraceId, - string? ActivitySpanId, - string? ActivityTraceFlags) + string ActivityTraceId, + string ActivitySpanId, + string ActivityTraceFlags) { Debug.Assert(LoggerName != null); Debug.Assert(ExceptionJson != null); Debug.Assert(ArgumentsJson != null); + Debug.Assert(ActivityTraceId != null); + Debug.Assert(ActivitySpanId != null); + Debug.Assert(ActivityTraceFlags != null); EventName ??= string.Empty; FormattedMessage ??= string.Empty; - ActivityTraceId ??= string.Empty; - ActivitySpanId ??= string.Empty; - ActivityTraceFlags ??= string.Empty; fixed (char* loggerName = LoggerName) fixed (char* eventName = EventName) From 0e968ae490776c6e21e41a2432bf39bb2129ea90 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 18 Jun 2024 11:49:31 -0700 Subject: [PATCH 3/4] Code review. --- .../tests/EventSourceLoggerTest.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs index 6727029755f8a..2673ac4ce9728 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs @@ -215,23 +215,23 @@ public void Logs_TracingDetailsAsExpected_WithDefaults(bool hasTrace, bool useW3 using Activity activity = new Activity("TestOperation"); - if (useW3CFormatId) - { - activity.SetIdFormat(ActivityIdFormat.W3C); - } - else - { - activity.SetIdFormat(ActivityIdFormat.Hierarchical); - } - if (hasTrace) { + if (useW3CFormatId) + { + activity.SetIdFormat(ActivityIdFormat.W3C); + } + else + { + activity.SetIdFormat(ActivityIdFormat.Hierarchical); + } + activity.Start(); - } - if (sampled) - { - activity.ActivityTraceFlags = ActivityTraceFlags.Recorded; + if (sampled) + { + activity.ActivityTraceFlags = ActivityTraceFlags.Recorded; + } } var logger = factory.CreateLogger("TestLogger"); From e69bc6433d6ea9cf57bc30303bfdfccfba507c01 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 21 Jun 2024 13:27:09 -0700 Subject: [PATCH 4/4] Test fix. --- .../tests/EventSourceLoggerTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs index b2341fd5db782..d7cdc0c52e2de 100644 --- a/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs +++ b/src/libraries/Microsoft.Extensions.Logging.EventSource/tests/EventSourceLoggerTest.cs @@ -649,7 +649,7 @@ public void Logs_AsExpected_MessageJson_WithNullString() // Write some MessageJson events with null string. for (var i = 0; i < 100; i++) { - LoggingEventSource.Instance.MessageJson(LogLevel.Trace, 1, "MyLogger", 5, null, "testJson", "testJson", "formattedMessage", null, null, null); + LoggingEventSource.Instance.MessageJson(LogLevel.Trace, 1, "MyLogger", 5, null, "testJson", "testJson", "formattedMessage", string.Empty, string.Empty, string.Empty); } bool containsNullEventName = false;