protected function symlink($target, $link, $logShort = false)
    {
        $fs = FileSystem::getFileSystem();

        // Convert target to relative path.
        $absolutePath = (new PhingFile($link))->getAbsolutePath();
        $link         = $absolutePath;

        if ($logShort) {
            $relativePath = str_replace(
                $this->getProject()->getBaseDir(),
                "", $absolutePath
            );
            $linkName     = basename($absolutePath);
        } else {
            $linkName = $link;
        }

        // @codingStandardsIgnoreLine: MULTISITE-17111
        $target = rtrim(
            $this->makePathRelative($target, dirname($link)),
            '/'
        );

        if (is_link($link) && @readlink($link) == $target) {
            $this->log('Link exists: '.$linkName, Project::MSG_INFO);

            return true;
        }

        if (file_exists($link) || is_link($link)) {
            if (!$this->getOverwrite()) {
                $this->log(
                    'Not overwriting existing link '.$link,
                    Project::MSG_ERR
                );

                return false;
            }

            if (is_link($link) || is_file($link)) {
                $fs->unlink($link);
                $this->log(
                    'Link removed: '.$linkName,
                    Project::MSG_INFO
                );
            } else {
                $fs->rmdir($link, true);
                $this->log(
                    'Directory removed: '.$linkName,
                    Project::MSG_INFO
                );
            }
        }

        $this->log('Linking: '.$linkName.' to '.$target, Project::MSG_INFO);

        return $fs->symlink($target, $link);

    }