我在运行 Gunicorn 时尝试这种日志格式:
--access-logformat "[dev.api] %(h)s %(l)s %(u)s %(t)s .%(r)s. %(s)s %(b)s .%(f)s. .%(a)s. conn=\"%{Connection}i\""
Run Code Online (Sandbox Code Playgroud)
根据文档@http: //docs.gunicorn.org/en/latest/configure.html ,这看起来没问题
但是,我收到以下错误:
File "lib/python2.7/site-packages/gunicorn/glogging.py", line 274, in access
self.access_log.info(self.cfg.access_log_format % safe_atoms)
TypeError: not enough arguments for format string
Run Code Online (Sandbox Code Playgroud)
问题与我请求连接请求标头的方式有关。
有人有以gunicorn 格式记录请求标头的示例吗?
根据我收集的信息,应该是:
--access-logformat "[dev.api] %(h)s %(l)s %(u)s %(t)s .%(r)s. %(s)s %(b)s .%(f)s. .%(a)s. conn=\"%({Connection}i)s\""
Run Code Online (Sandbox Code Playgroud)
也就是说%({Connection}i)s,%{Connection}i错误表明您的字符串中存在未知的替换,而最后一个是唯一不遵循该模式的东西,即 ,%(variable-name)s意味着s字符串替换。
另外,如果您正在寻找请求标头,它可能应该是:%({Header}i)s,不确定这是否会给您完整的标头,或者您是否可以Connection通过此显式选择标头。
不过,完全公开,我没有使用 Gunicorn 的经验,我只是在阅读文档。
| 归档时间: |
|
| 查看次数: |
5168 次 |
| 最近记录: |