protected function _setupLogging($loglevel)
    {
        // Backwards compatibility
        if (file_exists(JPATH_LIBRARIES . '/src/Log/Log.php')) {
          require_once JPATH_LIBRARIES . '/src/Log/Log.php';
        } else {
          require_once JPATH_LIBRARIES . '/joomla/log/log.php';
        }

        if ($loglevel == OutputInterface::VERBOSITY_NORMAL) {
            return;
        }

        switch ($loglevel)
        {
            case OutputInterface::VERBOSITY_DEBUG:
                $priority = JLog::ALL;
                break;
            case OutputInterface::VERBOSITY_VERY_VERBOSE:
                $priority = JLog::ALL & ~JLog::DEBUG;
                break;
            case OutputInterface::VERBOSITY_VERBOSE:
                $priority = JLog::ALL & ~JLog::DEBUG & ~JLog::INFO & ~JLog::NOTICE;
                break;
        }

        if ($this->_is_platform === true || version_compare(JVERSION, '3.0.0', '>='))
        {
            $callback = function ($entry) {
                $priorities = array(
                    JLog::EMERGENCY => 'EMERGENCY',
                    JLog::ALERT => 'ALERT',
                    JLog::CRITICAL => 'CRITICAL',
                    JLog::ERROR => 'ERROR',
                    JLog::WARNING => 'WARNING',
                    JLog::NOTICE => 'NOTICE',
                    JLog::INFO => 'INFO',
                    JLog::DEBUG => 'DEBUG'
                );

                $message = $priorities[$entry->priority] . ': ' . $entry->message . (empty($entry->category) ? '' : ' [' . $entry->category . ']') . "\n";

                fwrite(STDERR, $message);
            };

            $options = array('logger' => 'callback', 'callback' => $callback);
        }
        else
        {
            require_once dirname(__DIR__) . '/Joomla/Legacy/JLoggerStderr.php';

            $options = array('logger' => 'stderr');
        }


        JLog::addLogger($options, $priority);
    }