在过去的5个小时里一直在寻找答案,但什么也没找到。
我有一个flask(python 2.7)应用程序可以很好地与uwsgi配合使用,但我没有日志。
/etc/uwsgi/uwsgi。ini配置:
[uwsgi]
socket = /tmp/uwsgi.sock
chown-socket = nginx:nginx
chmod-socket = 664
cheaper = 2
processes = 16
/应用程序/uwsgi。ini公司
[uwsgi]
module = main
callable = app
/应用程序/主。py(在没有uwsgi的情况下工作正常)
app = Flask(__name__)
...
...
...
if __name__ == "__main__":
with open("{0}/logging.config.json".format(CONFIG_PATH), "r") as fd:
logging.config.dictConfig(json.load(fd))
app.run()
登录中。配置。json:
...
"formatters": {
"simple": {
"()": "pythonjsonlogger.jsonlogger.JsonFormatter",
"format": "%(asctime)s %(levelname)s %(module)s %(message)s"
}
...
"handlers": {
"console":{
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "simple",
"stream" : "ext://sys.stdout"
},
"loggers": { },
"root": {
"handlers": ["console"],
"level": "DEBUG"
}
}
我还尝试将记录器移到main之外(一篇帖子建议这样做),如下所示:
app = Flask(__name__)
with open("{0}/logging.config.json".format(CONFIG_PATH), "r") as fd:
logging.config.dictConfig(json.load(fd))
...
...
...
if __name__ == "__main__":
app.run()
它只是破坏了uwsgi:
--- no python application found, check your startup logs for errors ---
与应用程序声明之前的日志声明相同(但没有错误-应用程序无法工作)
有什么建议吗?