def configure_logging(app):
    """
    Sets up application wide logging.

    :param app:
    """
    logfile = app.config.get("LOG_FILE", "lemur.log")
    # if the log file is a character special device file (ie. stdout/stderr),
    # file rotation will not work and must be disabled.
    disable_file_rotation = os.path.exists(logfile) and stat.S_ISCHR(os.stat(logfile).st_mode)
    if disable_file_rotation:
        handler = StreamHandler(open(logfile, 'a'))
    else:
        handler = RotatingFileHandler(logfile, maxBytes=10000000, backupCount=100)

    handler.setFormatter(
        Formatter(
            "%(asctime)s %(levelname)s: %(message)s " "[in %(pathname)s:%(lineno)d]"
        )
    )

    if app.config.get("LOG_JSON", False):
        handler.setFormatter(
            JsonFormatter(fmt="%(asctime) %(name) %(processName) %(filename) %(funcName) %(levelname) %(lineno) %(module) %(threadName) %(message)",
                 datefmt="%Y-%m-%dT%H:%M:%SZ%z",
                 defaults={"hostname": socket.gethostname()})
        )

    handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.addHandler(handler)

    stream_handler = StreamHandler()
    stream_handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.addHandler(stream_handler)

    if app.config.get("DEBUG_DUMP", False):
        activate_debug_dump()

    Sets up application wide logging.

    :param app:
    
lemur/factory.py