我用运行金字塔的--paster选项启动gunicorn。
gunicorn -w 1 --paster development.ini例如,gunicorn自己的消息在控制台上显示得很好
2014-02-20 22:38:50 [44201] [INFO] Starting gunicorn 18.0
2014-02-20 22:38:50 [44201] [INFO] Listening at: http://0.0.0.0:6543 (44201)
2014-02-20 22:38:50 [44201] [INFO] Using worker: sync然而,我的金字塔应用程序中的日志消息并没有显示出来。
如果我使用pserve development.ini,它使用waitress作为WSGI服务器,日志消息在控制台上显示得很好。
我的development.ini包括一个非常普通的日志记录配置部分。
[loggers]
keys = root, apipython
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console
[logger_apipython]
level = DEBUG
handlers =
qualname = apipython
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = DEBUG
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s我搞不懂为什么当我使用gunicorn时,日志没有显示出来。
发布于 2014-06-21 03:12:44
不要将pserve与gunicorn一起使用,它已被弃用,并且很可能会在下一个版本中被删除。
Gunicorn有"logconfig" setting,只需通过命令行参数将其设置为您的配置即可:
gunicorn -w 1 --paster development.ini --log-config development.ini或者在相同的配置中:
[server:main]
use = egg:gunicorn#main
logconfig = %(here)s/development.ini发布于 2014-02-25 17:00:11
这是因为"pserve“命令不仅会启动服务器并加载应用程序,还会设置日志。而"gunicorn -paster“只是加载应用程序。要解决此问题,您可以在应用程序上显式设置日志记录:
from pyramid.config import Configurator
from pyramid.paster import setup_logging
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application. """
setup_logging(global_config['__file__'])
config = Configurator(settings=settings)
# Configure application
return config.make_wsgi_app()或者正如您在注释中指出的那样,在配置文件中更改服务器并使用"pserve“命令:
[server:main]
use = egg:gunicorn#main https://stackoverflow.com/questions/21927811
复制相似问题