将多个uwsgi记录器记录到stdout

时间:2018-11-17 17:33:30

标签: django logging stdout uwsgi

我在Django应用程序的Docker容器内运行uwsgi。我想以不同的方式记录uwsgi,request和django日志,因此我在.ini文件中创建了以下配置。

[uwsgi]
logger = main file:/dev/stdout
logger = django file:/dev/stdout
logger = req file:/dev/stdout

log-format = "method": "%(method)", "uri": "%(uri)", "proto": "%(proto)", "status": %(status), "referer": "%(referer)", "user_agent": "%(uagent)", "remote_addr": "%(addr)", "http_host": "%(host)", "pid": %(pid), "worker_id": %(wid), "core": %(core), "async_switches": %(switches), "io_errors": %(ioerr), "rq_size": %(cl), "rs_time_ms": %(msecs), "rs_size": %(size), "rs_header_size": %(hsize), "rs_header_count": %(headers), "event": "uwsgi_request"

log-route = main ^((?!django).)*$
log-route = django django
log-route = req uwsgi_request

log-encoder = format:django ${msg}
log-encoder = nl:django

log-encoder = json:main {"timestamp": "${strftime:%%Y-%%m-%%dT%%H:%%M:%%S+00:00Z}", "message":"${msg}","severity": "INFO"}
log-encoder = nl:main

log-encoder = format:req {"timestamp": "${strftime:%%Y-%%m-%%dT%%H:%%M:%%S}", ${msg}}
log-encoder = nl:req

问题在于,现在djangoreq的日志没有显示。我猜这是因为多个记录器想要写入/dev/stdout而不能写入。

我如何1.在将所有内容写入stdout的同时2.根据正则表达式对日志进行不同的格式化?


我通过打开一些日志路由并看到一切正常来确认是这种情况。

0 个答案:

没有答案