diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php
index 4a8079e2964a5c7b059cb893686ca76d8b30b25f..f804e43931ecb4852a1951913bc5100fb7398c88 100644
--- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php
+++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php
@@ -121,7 +121,7 @@ class SimpleSAML_Bindings_Shib13_Artifact {
 		$artifacts = self::getArtifacts();
 		$request = self::buildRequest($artifacts);
 
-		SimpleSAML_Utilities::debugMessage($msgStr, 'out');
+		\SimpleSAML\Utils\XML::debugSAMLMessage($request, 'out');
 
 		$url = $idpMetadata->getDefaultEndpoint('ArtifactResolutionService', array('urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding'));
 		$url = $url['Location'];
@@ -166,7 +166,7 @@ class SimpleSAML_Bindings_Shib13_Artifact {
 			throw new SimpleSAML_Error_Exception('Failed to retrieve assertion from IdP.');
 		}
 
-		SimpleSAML_Utilities::debugMessage($response, 'in');
+		\SimpleSAML\Utils\XML::debugSAMLMessage($response, 'in');
 
 		/* Find the response in the SOAP message. */
 		$response = self::extractResponse($response);
diff --git a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
index 86feff9eb5e19c32231850134e37c1a898c34763..9b39623a4ab6f15cf6c262eac9253eb304fb548a 100644
--- a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
+++ b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php
@@ -78,7 +78,7 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
 
 		$response = $responsedom->saveXML();
 
-		SimpleSAML_Utilities::debugMessage($response, 'out');
+		\SimpleSAML\Utils\XML::debugSAMLMessage($response, 'out');
 
 		\SimpleSAML\Utils\HTTP::submitPOSTData($shire, array(
 			'TARGET' => $relayState,
@@ -103,7 +103,7 @@ class SimpleSAML_Bindings_Shib13_HTTPPost {
 		$rawResponse = $post['SAMLResponse'];
 		$samlResponseXML = base64_decode($rawResponse);
 
-		SimpleSAML_Utilities::debugMessage($samlResponseXML, 'in');
+		\SimpleSAML\Utils\XML::debugSAMLMessage($samlResponseXML, 'in');
 
 		SimpleSAML_Utilities::validateXMLDocument($samlResponseXML, 'saml11');
 
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 3ffac923fb2bb6d3363fdc83ccffe6a02daeea4c..70251d1296179330b2976b8587386b6b9f87ebf0 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -886,45 +886,10 @@ class SimpleSAML_Utilities {
 
 
 	/**
-	 * Helper function to log messages that we send or receive.
-	 *
-	 * @param string|DOMElement $message  The message, as an XML string or an XML element.
-	 * @param string $type  Whether this message is sent or received, encrypted or decrypted.
+	 * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::debugSAMLMessage() instead.
 	 */
 	public static function debugMessage($message, $type) {
-		assert('is_string($message) || $message instanceof DOMElement');
-
-		$globalConfig = SimpleSAML_Configuration::getInstance();
-		if (!$globalConfig->getBoolean('debug', FALSE)) {
-			/* Message debug disabled. */
-			return;
-		}
-
-		if ($message instanceof DOMElement) {
-			$message = $message->ownerDocument->saveXML($message);
-		}
-
-		switch ($type) {
-		case 'in':
-			SimpleSAML_Logger::debug('Received message:');
-			break;
-		case 'out':
-			SimpleSAML_Logger::debug('Sending message:');
-			break;
-		case 'decrypt':
-			SimpleSAML_Logger::debug('Decrypted message:');
-			break;
-		case 'encrypt':
-			SimpleSAML_Logger::debug('Encrypted message:');
-			break;
-		default:
-			assert(FALSE);
-		}
-
-		$str = SimpleSAML\Utils\XML::formatXMLString($message);
-		foreach (explode("\n", $str) as $line) {
-			SimpleSAML_Logger::debug($line);
-		}
+		return \SimpleSAML\Utils\XML::debugSAMLMessage($message, $type);
 	}
 
 
diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php
index e18d7ff74dfb45f1a61d99d152ecc0ae6e54ffba..f594752d55ca343484685433b44f3a03dab67784 100644
--- a/lib/SimpleSAML/Utils/XML.php
+++ b/lib/SimpleSAML/Utils/XML.php
@@ -11,6 +11,61 @@ namespace SimpleSAML\Utils;
 class XML
 {
 
+    /**
+     * Helper function to log SAML messages that we send or receive.
+     *
+     * @param string|\DOMElement $message The message, as an string containing the XML or an XML element.
+     * @param string            $type Whether this message is sent or received, encrypted or decrypted. The following
+     *     values are supported:
+     *      - 'in': for messages received.
+     *      - 'out': for outgoing messages.
+     *      - 'decrypt': for decrypted messages.
+     *      - 'encrypt': for encrypted messages.
+     *
+     * @throws \SimpleSAML_Error_Exception If $type is not a string or $message is neither a string nor a \DOMElement.
+     *
+     * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+     */
+    public static function debugSAMLMessage($message, $type)
+    {
+        if (!(is_string($type) && (is_string($message) || $message instanceof \DOMElement))) {
+            throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
+        }
+
+        $globalConfig = \SimpleSAML_Configuration::getInstance();
+        if (!$globalConfig->getBoolean('debug', false)) {
+            // message debug disabled
+            return;
+        }
+
+        if ($message instanceof \DOMElement) {
+            $message = $message->ownerDocument->saveXML($message);
+        }
+
+        switch ($type) {
+            case 'in':
+                \SimpleSAML_Logger::debug('Received message:');
+                break;
+            case 'out':
+                \SimpleSAML_Logger::debug('Sending message:');
+                break;
+            case 'decrypt':
+                \SimpleSAML_Logger::debug('Decrypted message:');
+                break;
+            case 'encrypt':
+                \SimpleSAML_Logger::debug('Encrypted message:');
+                break;
+            default:
+                assert(false);
+        }
+
+        $str = self::formatXMLString($message);
+        foreach (explode("\n", $str) as $line) {
+            \SimpleSAML_Logger::debug($line);
+        }
+    }
+
+
     /**
      * Format a DOM element.
      *