This product is not supported for your selected Datadog site. ().
이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다. 현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.
Metadata
ID:csharp-security/logging-exception
Language: C#
Severity: Info
Category: Best Practices
Description
This rule discourages logging only the exception message without including the full exception object. Logging just the exception message can omit valuable context, such as the stack trace, which is essential for diagnosing and troubleshooting issues effectively.
To comply with this rule, always pass the exception object as a parameter to your logging method instead of concatenating or interpolating the exception message into the log string. For example, use logger.error("Error processing file", e); rather than logger.error($"Error: {e.Message}");. This practice ensures that the logging framework captures the full exception details, including stack traces and inner exceptions.
Note that you may still want to log the full exception of part of its attribute. In this case, you can disable this rule for your repository or organization.