def setup(
    config_file,
    redirect_stderr=True,
    excludes=None,
    disable_existing_loggers=False,
    st2_conf_path=None,
):
    """
    Configure logging from file.

    :param st2_conf_path: Optional path to st2.conf file. If provided and "config_file" path is
                          relative to st2.conf path, the config_file path will get resolved to full
                          absolute path relative to st2.conf.
    :type st2_conf_path: ``str``
    """
    if st2_conf_path and config_file[:2] == "./" and not os.path.isfile(config_file):
        # Logging config path is relative to st2.conf, resolve it to full absolute path
        directory = os.path.dirname(st2_conf_path)
        config_file_name = os.path.basename(config_file)
        config_file = os.path.join(directory, config_file_name)

    try:
        logging.config.fileConfig(
            config_file,
            defaults=None,
            disable_existing_loggers=disable_existing_loggers,
        )
        handlers = logging.getLoggerClass().manager.root.handlers
        _add_exclusion_filters(handlers=handlers, excludes=excludes)
        if redirect_stderr:
            _redirect_stderr()
        _patch_stdout()
    except Exception as exc:
        exc_cls = type(exc)
        tb_msg = traceback.format_exc()

        msg = str(exc)
        msg += "\n\n" + tb_msg

        # revert stderr redirection since there is no logger in place.
        sys.stderr = sys.__stderr__

        # No logger yet therefore write to stderr
        sys.stderr.write("ERROR: %s" % (msg))

        raise exc_cls(six.text_type(msg))

    Configure logging from file.

    :param st2_conf_path: Optional path to st2.conf file. If provided and "config_file" path is
                          relative to st2.conf path, the config_file path will get resolved to full
                          absolute path relative to st2.conf.
    :type st2_conf_path: ``str``
    
st2common/st2common/log.py