Skip to content

Duplicate Log Message (ARCH4162)

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.

if (user == null) {
log.warn("Invalid request");
return;
}
if (token.expired()) {
log.warn("Invalid request");
return;
}
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.