Inappropriate Log Level (ARCH4161)
Ce contenu n’est pas encore disponible dans votre langue.
Key java.logging.inappropriate-log-level · Severity info · Category logging
Logging errors at info/debug causes warnings to be missed, while logging routine flow at error drowns real failures in noise. Choose the level based on the severity of the event.
Incorrect
Section titled “Incorrect”try { payment.charge(amount);} catch (PaymentException e) { log.info("Payment failed", e);}Correct
Section titled “Correct”try { payment.charge(amount);} catch (PaymentException e) { log.error("Payment failed: {}", amount, e);}Choose the log level by the event’s real severity: errors at error, warnings at warn, routine info at info.