我正在尝试为 Python Pyramid Waitress Server 设置日志记录。我在这里关注了文档: Pyramid logging和这里:Pyramid PasteDeploy logging。我已经厌倦了这两种方法都没有产生女服务员的记录结果。我自己的日志记录工作完美。
我已将 Waitress 日志记录级别设置为 DEBUG,即使我删除了服务器文件,我也什么也得不到。女服务员默默地让服务器失败。
您如何为 Pyramid Waitress 服务器设置日志记录,以便我可以看到请求的文件、丢失的文件错误等?
方法1:从代码设置:
import logging
logging.basicConfig()
logger = logging.getLogger('waitress')
logger.setLevel(logging.DEBUG)
方法 2:使用 pserve development.ini 启动服务器,其中 development.ini 文件设置日志记录如下
[app:main]
use = egg:MyProject
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_debugtoolbar
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
[loggers]
keys = root, myproject, waitress
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console
[logger_myproject]
level = DEBUG
handlers =
qualname = myproject
[logger_waitress]
level = DEBUG
handlers =
qualname = waitress
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s