code: public static void log(Logger logger, SQLException e) {
      SQLException next = e.getNextException();
      while (next != null) {
        logger.error("SQL error: {}. Message: {}", next.getSQLState(), next.getMessage());
        next = next.getNextException();
      }
    }
docs: Logback does not log exceptions associated to {@link java.sql.SQLException#getNextException()}.
  See http://jira.qos.ch/browse/LOGBACK-775