diff --git a/typo3/sysext/adminpanel/ext_localconf.php b/typo3/sysext/adminpanel/ext_localconf.php
index e92f01dd44f4f21f71e353905a53b90fe2b68af3..12d68037077bf497041a8b6bc690227077e3d701 100644
--- a/typo3/sysext/adminpanel/ext_localconf.php
+++ b/typo3/sysext/adminpanel/ext_localconf.php
@@ -61,7 +61,10 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules'] = [
 $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['adminPanel_save']
     = \TYPO3\CMS\Adminpanel\Controller\AjaxController::class . '::saveDataAction';
 
-$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::DEBUG][\TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter::class] = [];
+// Only write to InMemoryLog if in frontend and not in CLI mode
+if (TYPO3_MODE === 'FE' && !\TYPO3\CMS\Core\Core\Environment::isCli()) {
+    $GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][\TYPO3\CMS\Core\Log\LogLevel::DEBUG][\TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter::class] = [];
+}
 
 if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['adminpanel_requestcache'])) {
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['adminpanel_requestcache'] = [];