Lee's Space Station

gunicorn accesslog 为空的一种可能解决办法

2019/12/11 Share

WHY？

分析

Warning The fileConfig() function takes a default parameter, disable_existing_loggers, which defaults to True for reasons of backward compatibility. This may or may not be what you want, since it will cause any non-root loggers existing before the fileConfig() call to be disabled unless they (or an ancestor) are explicitly named in the configuration. Please refer to the reference documentation for more information, and specify False for this parameter if you wish.

The dictionary passed to dictConfig() can also specify a Boolean value with key disable_existing_loggers, which if not specified explicitly in the dictionary also defaults to being interpreted as True. This leads to the logger-disabling behaviour described above, which may not be what you want - in which case, provide the key explicitly with a value of False.

OK，那么这和 gunicorn 有什么关系呢？

gunicorn 实际上也是使用的 logging 模块。在真正的启动 flask 服务之前，gunicorn 会先启动，并输出类似如下的信息到 gunicorn_error.log

CATALOG