Duplicate Log Message (ARCH4162)
Ce contenu n’est pas encore disponible dans votre langue.
Key java.logging.duplicate-log-message · Severity info · Category logging
Repeating an identical log message within the same class makes a log line ambiguous about which code path produced it. Finding the right source during diagnosis becomes impossible.
Incorrect
Section titled “Incorrect”if (user == null) { log.warn("Invalid request"); return;}if (token.expired()) { log.warn("Invalid request"); return;}Correct
Section titled “Correct”if (user == null) { log.warn("Invalid request: user not found"); return;}if (token.expired()) { log.warn("Invalid request: token expired"); return;}Make each log message specific to its context so it is clear which code path produced it.