Selaa lähdekoodia

[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 14 vuotta sitten
vanhempi
commit
838853e58b
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  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);
             }