تخطَّ إلى المحتوى

Hardcoded log message (ARCH1010)

هذا المحتوى غير متوفر بلغتك بعد.

Key dotnet.logging.hardcoded-log-message · Severity info · Category logging

When the same log text is hardcoded in multiple places it becomes hard to maintain and risks inconsistency. Extract repeated text into constants.

_logger.LogWarning("Retry limit exceeded");
// elsewhere
_logger.LogWarning("Retry limit exceeded");
private const string RetryLimitExceeded = "Retry limit exceeded";
_logger.LogWarning(RetryLimitExceeded);

Move the repeated log text into a const field and reference that constant from every call site.