Browse Source

[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 năm trước cách đây
mục cha
commit
838853e58b

+ 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);
             }