diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index f85706bd9259f1ec33d62932be34529250ee2caa..7af8d842ce56d4cea5fd4c315b5a3816abc8213a 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -107,8 +107,8 @@ class sspmod_saml_IdP_SAML2 {
 
 		$error = sspmod_saml_Error::fromException($exception);
 
-		SimpleSAML\Logger::warning('Returning error to sp: ' . var_export($spEntityId, TRUE));
-		$error->logWarning();
+		SimpleSAML\Logger::warning("Returning error to SP with entity ID '".var_export($spEntityId, TRUE)."'.");
+		$exception->log(SimpleSAML\Logger::WARNING);
 
 		$ar = self::buildResponse($idpMetadata, $spMetadata, $consumerURL);
 		$ar->setInResponseTo($requestId);