public function logException(FlattenException $exception, Request $request)
    {
        $ex = new Exception5xx();
        $ex->setStatusCode($this->getStatusCode($exception));
        $ex->setFile($exception->getFile());
        $ex->setLine($exception->getLine());
        $ex->setTrace($this->getTrace($exception->getTrace()));
        $ex->setMessage($exception->getMessage());
        $ex->setRequestUrl($request->getRequestUri());
        $ex->setReferrer($request->server->get('HTTP_REFERER'));
        $ex->setUserAgent($request->server->get('HTTP_USER_AGENT'));
        $ex->setRemoteIp($request->server->get('REMOTE_ADDR'));
        $ex->setMethod($request->server->get('REQUEST_METHOD'));
        $ex->setQueryString($request->server->get('QUERY_STRING'));
        $ex->setHostname($request->getHttpHost());
        $ex->setRequest(Flattener::flattenArrayToString($request->request->all()));
        $ex->setLogged(new \DateTime("now"));
        try {
            $manager = $this->registry->getManagerForClass('EXSErrorBundle:Exception5xx');
            $manager->persist($ex);
            //you dont want to flush the full entity manager. only the error.
            $manager->flush($ex);
        } catch (\Exception $e) {
            //silence
        }
    }