有没有办法从 uwsgi 格式化时间戳

boa*_*der 5 logging uwsgi

这些是 uwsgi logformat 的文档。

http://uwsgi-docs.readthedocs.io/en/latest/LogFormat.html

我有几个不可接受的选择来在日志消息中输出时间戳。有没有办法格式化 YYYY-MM-DD HH-MM-SS.DDDDDD 只是没有记录?

boa*_*der 7

通过阅读github上的代码,我发现了一个暗示解决方案的问题。

这是我最终使用的命令行

uwsgi --log-date="%Y:%m:%d %H:%M:%S" --logformat-strftime --logformat="%(ftime) %(addr) (%(proto) %(status)) %(method) %(uri) : Retned %(size) bytes in %(msecs) msecs to %(uagent)" --http :9090 --wsgi-file foo.py 
Run Code Online (Sandbox Code Playgroud)

通过阅读文档,我几乎无法想到这一点。它确实需要所有 3 个选项(不确定顺序是否重要)和 (%ftime) 的使用,这在 logformat 文档页面上根本没有提到,仅在其中一个版本的更改日志中。

似乎不可能在日志行中获得毫秒数