Exception logging (ARCH1003)
هذا المحتوى غير متوفر بلغتك بعد.
Key dotnet.logging.exception-logging · Severity warning · Category logging
Logging only the message in a catch block loses the stack trace. Pass the exception object as the first argument.
Incorrect
Section titled “Incorrect”catch (Exception ex){ _logger.LogError("Payment failed: {Message}", ex.Message);}Correct
Section titled “Correct”catch (Exception ex){ _logger.LogError(ex, "Payment failed");}Add the exception object as the first parameter of the LogError call so the stack trace is preserved.