Hardcoded log message (ARCH1010)
Esta página aún no está disponible en tu idioma.
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.
Incorrect
Section titled “Incorrect”_logger.LogWarning("Retry limit exceeded");// elsewhere_logger.LogWarning("Retry limit exceeded");Correct
Section titled “Correct”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.