Quellcode durchsuchen

[HttpKernel] Log 500+ errors as critical and not error

This allows people to filter easily between 404 type of responses (that are mostly for users) and real errors in their application (where they probably want to get an email notification
Jordi Boggiano vor 14 Jahren
Ursprung
Commit
838853e58b
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php

+ 5 - 1
src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php

@@ -77,7 +77,11 @@ class ExceptionListener
         } catch (\Exception $e) {
             $message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
             if (null !== $this->logger) {
-                $this->logger->err($message);
+                if ($exception instanceof HttpExceptionInterface && $exception->getStatusCode() > 500) {
+                    $this->logger->crit($message);
+                } else {
+                    $this->logger->err($message);
+                }
             } else {
                 error_log($message);
             }