【发布时间】:2015-10-19 14:26:49
【问题描述】:
我已经使用 Python Paste Deploy 脚本来部署 Flask+Gunicorn 项目。但是,我不能在 (h)s %(l)s %(u)s %(t)s "%(r)s" %(s 的部署脚本中编写 access_log_format )s %(b)s "%(f)"。因为我们的 %(h)s 格式在 Paste Deploy 脚本中有特殊的含义。如文档中所述:
You can use variable substitution, which will pull variables from
the section [DEFAULT] (case sensitive!) with markers like %
(var_name)s. The special variable %(here)s is the directory
containing the configuration file;
但是我可以解决这个问题吗?
【问题讨论】:
-
你试过用引号包裹字符串吗? (例如
access_log_format = '%(h)s') -
您能否将
access_log_format字段移至[DEFAULT]之外的部分?该措辞暗示变量替换仅在该配置部分中起作用。在我自己的 Pyramid 应用程序中,日志配置看起来很像 Pyramid logging configuration 中的示例 -
@IanMarcinkowski 不,我把它放在 [server:main] 部分,而不是 [DEFAULT] 部分。
标签: python python-paste