diff --git a/typo3/sysext/core/Classes/Log/Writer/FileWriter.php b/typo3/sysext/core/Classes/Log/Writer/FileWriter.php
index d15946acdbe6a10348c82a9bd9b043ff27d9e873..f54532d98ff4d4f5968d12770a2614ea36d9ebc8 100644
--- a/typo3/sysext/core/Classes/Log/Writer/FileWriter.php
+++ b/typo3/sysext/core/Classes/Log/Writer/FileWriter.php
@@ -216,13 +216,19 @@ class FileWriter extends AbstractWriter
         if (file_exists($this->logFile)) {
             return;
         }
-        $logFileDirectory = PathUtility::dirname($this->logFile);
-        if (!@is_dir($logFileDirectory)) {
-            GeneralUtility::mkdir_deep($logFileDirectory);
-            // create .htaccess file if log file is within the site path
-            if (PathUtility::getCommonPrefix([Environment::getPublicPath() . '/', $logFileDirectory]) === (Environment::getPublicPath() . '/')) {
-                // only create .htaccess, if we created the directory on our own
-                $this->createHtaccessFile($logFileDirectory . '/.htaccess');
+
+        // skip mkdir if logFile refers to any scheme but vfs://, file:// or empty
+        $scheme = parse_url($this->logFile, PHP_URL_SCHEME);
+        if ($scheme === null || $scheme === 'file' || $scheme === 'vfs') {
+            // remove file:/ before creating the directory
+            $logFileDirectory = PathUtility::dirname(preg_replace('#^file:/#', '', $this->logFile));
+            if (!@is_dir($logFileDirectory)) {
+                GeneralUtility::mkdir_deep($logFileDirectory);
+                // create .htaccess file if log file is within the site path
+                if (PathUtility::getCommonPrefix([Environment::getPublicPath() . '/', $logFileDirectory]) === (Environment::getPublicPath() . '/')) {
+                    // only create .htaccess, if we created the directory on our own
+                    $this->createHtaccessFile($logFileDirectory . '/.htaccess');
+                }
             }
         }
         // create the log file