TYPO3: Oops, an error occurred!

On your TYPO3 production machine (TYPO3_CONTEXT=Production) an extbase plugin crashes and only leaves a cryptic message:

Oops, an error occurred! Code: 201605240939366c16aa1f

If you did not modify TYPO3's error handling , the real error message is logged by TYPO3\CMS\Core\Log\Writer\FileWriter into typo3temp/logs/typo3_*.log.

This does of course not help if you don't have SSH access to the live server. The exceptions also do not follow normal error flow - which means a docker logs -f does not show it, and they will also not show up on your log server.

To fix this, overwrite the default configuration in typo3conf/AdditionalConfiguration.php:

<?php
// configure default logger to log to nginx error log
// so that we'll see this in graylog
$GLOBALS['TYPO3_CONF_VARS']['LOG'] = [
     'writerConfiguration' => [
         \TYPO3\CMS\Core\Log\LogLevel::WARNING => [
             \TYPO3\CMS\Core\Log\Writer\PhpErrorLogWriter::class => []
         ]
     ]
];

Do not try to put this into typo3conf/LocalConfiguration.php; TYPO3 will merge it with the default config, leaving you with both FileWriter and PhpErrorLogWriter. TYPO3's default configuration is defined in typo3/sysext/core/Configuration/DefaultConfiguration.php.

Written by Christian Weiske.

Comments? Please send an e-mail.