protected function logException(\Exception $e, $action = null, $level = LogLevel::ERROR)
    {
        $message = $action
            ? sprintf('%s failed: %s', $action, $e->getMessage())
            : sprintf('%s: %s', get_class($e), $e->getMessage());
        $this->getLogger()->log($level, $message, ['backtrace' => $e->getTraceAsString()]);
    }