Python Flask/wsgi-写入日志文件或触摸随机文件时权限被拒绝

Python Flask/wsgi-写入日志文件或触摸随机文件时权限被拒绝,python,apache,logging,flask,mod-wsgi,Python,Apache,Logging,Flask,Mod Wsgi,我正在编写一个非常简单的Flask程序来记录POST负载。它在调试中运行良好,所以我将其连接到apache。现在我开始 “IOError:[Errno 13]权限被拒绝:”尝试登录除/tmp以外的任何位置时 我正在RHEL7.x上运行apache v2.4.6和wsgi v3.4。 这是我的东西: vhost文件: Listen*:8080 服务器名www.test.com ErrorLog/var/log/httpd/error2.log CustomLog/var/log/httpd/ac

我正在编写一个非常简单的Flask程序来记录POST负载。它在调试中运行良好,所以我将其连接到apache。现在我开始 “IOError:[Errno 13]权限被拒绝:”尝试登录除/tmp以外的任何位置时

我正在RHEL7.x上运行apache v2.4.6和wsgi v3.4。 这是我的东西:

vhost文件:

Listen*:8080
服务器名www.test.com
ErrorLog/var/log/httpd/error2.log
CustomLog/var/log/httpd/access2.log组合
#没用
#
#选项索引如下SYMLINKS包括ExecCGI
#允许超越所有
#要求所有授权
#
WSGIDaemonProcess csplogger用户=apache组=apache线程=5
WSGIProcessGroup CSPGLogger
WSGIScriptAlias/report to/var/www/FLASKAPPS/csploger/csploger.wsgi

我遇到了这个问题,我解决这个问题的方法可能不是直接解决这个问题的方法,但它对我有效

我没有配置
app.logger
,而是直接从日志记录包创建了记录器:

if not app.debug:

    logdir = '/opt/logs/'

    file_handler = FileHandler('/tmp/access.log')
    #file_handler = FileHandler(logdir + 'access.log')
    #file_handler = RotatingFileHandler(logdir + 'access.log', maxBytes=20000000, backupCount=10)
    file_handler.setFormatter(Formatter('%(asctime)s %(levelname)s: %(message)s'))

    logging.getLogger('werkzeug').setLevel(logging.INFO)
    logging.getLogger('werkzeug').addHandler(file_handler)

    logger = logging.getLogger(__name__) 

    logger.addHandler(file_handler)
    logger.setLevel(logging.INFO)

    # adding some debug
    logger.info(os.environ)
    logger.info(os.path.dirname(logdir).format())
    logger.info(os.listdir(logdir))

app.logger
保留在适当位置的实际解决方案也可能与此相关。类似于:
app.logger=logging.getLogger(\uuuu name\uuuuuu)
但我自己还没有尝试过。

这个问题不好吗?这是一件太简单而不值得回答的事情吗?或者没有其他人看到它?有解决它的机会吗?