Преглед на файлове

[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 години
родител
ревизия
838853e58b
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  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);
             }