diff --git a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs index 06efe62..9a82609 100644 --- a/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs +++ b/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs @@ -167,10 +167,10 @@ LogEvent PrepareWrite(LogEventLevel level, EventId eventId, TState state static object? AsLoggableValue(TState state, Func? formatter) { - object? stateObj = state; + object? stateObj = null; if (formatter != null) stateObj = formatter(state, null); - return stateObj; + return stateObj ?? state; } internal static LogEventProperty CreateEventIdProperty(EventId eventId)