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

Exception Not Logged With Object (ARCH4159)

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

Key java.logging.exception-not-logged · Severity warning · Category logging

Logging only a message string in a catch block without passing the exception object loses the stack trace and the root cause. Pass the exception as the last argument to the logger.

try {
repository.save(user);
} catch (SQLException e) {
log.error("Save failed: " + e.getMessage());
}
try {
repository.save(user);
} catch (SQLException e) {
log.error("Save failed: {}", user.id(), e);
}

Pass the exception object as the last argument to the logger call so the full stack trace is recorded.