diff --git a/src/SimpleSAML/Kernel.php b/src/SimpleSAML/Kernel.php
index 3473a0fa682100190812770376496539e0eab320..344b1bcf9251d6daafe94412769a6177b1b1e7d3 100644
--- a/src/SimpleSAML/Kernel.php
+++ b/src/SimpleSAML/Kernel.php
@@ -66,7 +66,13 @@ class Kernel extends BaseKernel
     public function getLogDir(): string
     {
         $configuration = Configuration::getInstance();
-        $loggingPath = $configuration->getString('loggingdir');
+        $handler = $configuration->getString('logging.handler');
+
+        if ($handler === 'file') {
+            $loggingPath = $configuration->getString('loggingdir');
+        } else {
+            $loggingPath = '/dev/null';
+        }
 
         $sysUtils = new System();
         if ($sysUtils->isAbsolutePath($loggingPath)) {