如何使用 gunicorn 和 multiprocessing 登录?

How do I log using gunicorn and multiprocessing?

如何使用 python 日志记录在多处理 gunicorn(和 Flask)应用程序中记录我的应用程序代码(不是访问日志)?

我需要集中式日志记录解决方案还是我可以以某种方式使用文件?将每个进程指向同一个文件是否安全?

您可以使用多处理记录器:

https://docs.python.org/2/library/multiprocessing.html#logging

或者,如果您愿意,可以通过将 pid 连接到文件名来将日志写入每个进程中的不同文件