protected function buildLogMessage($appendAdditionalInformation = true)
    {
        $logMessage = $this->getMessage();

        if ($appendAdditionalInformation && !empty($this->additionalInformation)) {
            $logMessage .= ': ' . $this->additionalInformation;
        }

        $logMessage .= "\n";

        // Add tracing information to the message

        $previous = $this->getPreviousException();
        $trace    = $previous
            ? $previous->getTraceAsString()
            : $this->getTraceAsString();
        $line     = $previous
            ? $previous->getLine()
            : $this->getLine();
        $file     = $previous
            ? $previous->getFile()
            : $this->getFile();
        $class    = $previous
            ? get_class($previous)
            : get_class($this);

        $traceLines = explode("\n", $trace);
        array_unshift($traceLines, "## $file($line): throw $class");
        $i = 0;
        foreach ($traceLines as $traceLine) {
            $i++;
            if ($i > 20) {
                $logMessage .= "\t(...)";
                break;
            }
            $logMessage .= "\t$traceLine\n";
        }

        return $logMessage;
    }