@Override
  public void notifyAlertReceived(short alertLevel, short alertDescription) {
    TlsError error = new TlsError(alertLevel, alertDescription);
    if (alertLevel == AlertLevel.warning && logger.isInfoEnabled()) {
      logger.info("TLS warning received.");
      logger.info(error.toString());
    } else if (alertLevel == AlertLevel.fatal) {
      logger.error("TLS error received.");
      logger.error(error.toString());
    }

    super.notifyAlertReceived(alertLevel, alertDescription);
  }
  @Override
  public void notifyAlertRaised(
      short alertLevel, short alertDescription, String message, Throwable cause) {
    TlsError error = new TlsError(alertLevel, alertDescription, message, cause);
    if (alertLevel == AlertLevel.warning && logger.isInfoEnabled()) {
      logger.info("TLS warning sent.");
      if (logger.isDebugEnabled()) {
        logger.info(error.toString(), cause);
      } else {
        logger.info(error.toString());
      }
    } else if (alertLevel == AlertLevel.fatal) {
      logger.error("TLS error sent.");
      logger.error(error.toString(), cause);
    }

    super.notifyAlertRaised(alertLevel, alertDescription, message, cause);
  }