diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php
index c0a47057d451bc73cf4e55637648f02f94f84059..75383fafde750e3267a2a2cd757b68b4cf5c9646 100644
--- a/lib/SimpleSAML/Memcache.php
+++ b/lib/SimpleSAML/Memcache.php
@@ -1,6 +1,7 @@
 <?php
 
 require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Configuration.php');
+require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Logger.php');
 
 /**
  * This file implements functions to read and write to a group of memcache
@@ -57,17 +58,17 @@ class SimpleSAML_Memcache {
 			 * - 'data': The data.
 			 */
 			if(!is_array($info)) {
-				error_log('Retrieved invalid data from a memcache server.' .
+				SimpleSAML_Logger::warning('Retrieved invalid data from a memcache server.' .
 					' Data was not an array.');
 				continue;
 			}
 			if(!array_key_exists('timestamp', $info)) {
-				error_log('Retrieved invalid data from a memcache server.' .
+				SimpleSAML_Logger::warning('Retrieved invalid data from a memcache server.' .
 					' Missing timestamp.');
 				continue;
 			}
 			if(!array_key_exists('data', $info)) {
-				error_log('Retrieved invalid data from a memcache server.' .
+				SimpleSAML_Logger::warning('Retrieved invalid data from a memcache server.' .
 					' Missing data.');
 				continue;
 			}
@@ -358,18 +359,14 @@ class SimpleSAML_Memcache {
 
 		/* The 'memcache_store.expires' option must be an integer. */
 		if(!is_integer($expire)) {
-			$e = 'The value of \'memcache_store.expires\' in the' .
-			     ' configuration must be a valid integer.';
-			error_log($e);
-			die($e);
+			throw new Exception('The value of \'memcache_store.expires\' in the' .
+				' configuration must be a valid integer.');
 		}
 
 		/* It must be a positive integer. */
 		if($expire < 0) {
-			$e = 'The value of \'memcache_store.expires\' in the' .
-			     ' configuration can\'t be a negative integer.';
-			error_log($e);
-			die($e);
+			throw new Exception('The value of \'memcache_store.expires\' in the' .
+				' configuration can\'t be a negative integer.');
 		}
 
 		/* If the configuration option is 0, then we should
diff --git a/lib/SimpleSAML/MemcacheStore.php b/lib/SimpleSAML/MemcacheStore.php
index 1cc9206f8d4f69960d83e6952a6ac1cb0e0b831c..b0b084ffc1381e42f6378712a834acdcff3f05ad 100644
--- a/lib/SimpleSAML/MemcacheStore.php
+++ b/lib/SimpleSAML/MemcacheStore.php
@@ -3,6 +3,7 @@
 require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Utilities.php');
 require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/ModifiedInfo.php');
 require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Memcache.php');
+require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Logger.php');
 
 /**
  * This class provides a class with behaviour similar to the $_SESSION variable.
@@ -66,7 +67,7 @@ class SimpleSAML_MemcacheStore {
 		}
 
 		if(!($data instanceof self)) {
-			error_log('Retrieved key from memcache did not contain a MemcacheStore object.');
+			SimpleSAML_Logger::warning('Retrieved key from memcache did not contain a MemcacheStore object.');
 			return NULL;
 		}