Skip to content

Commit 4dc1a81

Browse files
committed
handle exception extra keys
1 parent 456abe8 commit 4dc1a81

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,9 @@ public static void LogCritical<T>(this ILogger logger, T extraKeys, string messa
580580
public static void Log<T>(this ILogger logger, LogLevel logLevel, T extraKeys, EventId eventId, Exception exception,
581581
string message, params object[] args) where T : class
582582
{
583-
if (extraKeys is not null)
583+
if (extraKeys is Exception ex && exception is null)
584+
logger.Log(logLevel, eventId, ex, message, args);
585+
else if (extraKeys is not null)
584586
using (logger.BeginScope(extraKeys))
585587
logger.Log(logLevel, eventId, exception, message, args);
586588
else

0 commit comments

Comments
 (0)