diff --git a/Classes/Controller/FrontendController.php b/Classes/Controller/FrontendController.php index 63840c29..d90e099b 100644 --- a/Classes/Controller/FrontendController.php +++ b/Classes/Controller/FrontendController.php @@ -27,6 +27,7 @@ use In2code\Lux\Exception\EmailValidationException; use In2code\Lux\Exception\FakeException; use In2code\Lux\Utility\BackendUtility; +use In2code\Lux\Utility\ConfigurationUtility; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; @@ -456,11 +457,13 @@ protected function getError(Throwable $exception): array { $this->eventDispatcher->dispatch(new AfterTrackingEvent(new Visitor(), 'error', ['error' => $exception])); if (BackendUtility::isBackendAuthentication() === false) { - // Log error to var/log/typo3_[hash].log - $this->logger->warning('Error in FrontendController happened', [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage(), - ]); + if (ConfigurationUtility::isExceptionLoggingActivated()) { + // Log error to var/log/typo3_[hash].log + $this->logger->warning('Error in FrontendController happened', [ + 'code' => $exception->getCode(), + 'message' => $exception->getMessage(), + ]); + } $exception = new FakeException('Error happened', 1680200937); } return [ diff --git a/Classes/Utility/ConfigurationUtility.php b/Classes/Utility/ConfigurationUtility.php index f9940d20..27457f65 100644 --- a/Classes/Utility/ConfigurationUtility.php +++ b/Classes/Utility/ConfigurationUtility.php @@ -203,6 +203,17 @@ public static function isAnalysisModuleDisabled(): bool return $extensionConfig['disableAnalysisModule'] === '1'; } + /** + * @return bool + * @throws ExtensionConfigurationExtensionNotConfiguredException + * @throws ExtensionConfigurationPathDoesNotExistException + */ + public static function isExceptionLoggingActivated(): bool + { + $extensionConfig = self::getExtensionConfiguration(); + return $extensionConfig['enbaleExceptionLogging'] === '1'; + } + /** * @return bool * @throws ExtensionConfigurationExtensionNotConfiguredException diff --git a/ext_conf_template.txt b/ext_conf_template.txt index bc07ddbf..75eefe15 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -54,3 +54,6 @@ showRenderTimes = 0 # cat=advanced/enable/270; type=boolean; label= Use cache layer: Performance boost for backend views. Cache layer could be used for both dashboard views and quick analyse in page overview view. Lifetime is per default 24h and caches can be warmed up via scheduler task. useCacheLayer = 1 + +# cat=advanced/enable/280; type=boolean; label= Enable exception logging: If the user is not logged in into backend and an exception happens, those exceptions can be logged as warning in var/log/typo3_[hash].log +enbaleExceptionLogging = 1