Skip to content

Instantly share code, notes, and snippets.

@k-kawashiman
Forked from amgorb/uwsgi.conf
Created April 15, 2021 11:00
Show Gist options
  • Save k-kawashiman/f364560733df3f04abd2895c0423680a to your computer and use it in GitHub Desktop.
Save k-kawashiman/f364560733df3f04abd2895c0423680a to your computer and use it in GitHub Desktop.
uWSGI separate JSON logging for application compatible with Elasticsearch
[uwsgi]
;this will encode uwsgi messages into JSON, encode requests to JSON and leave application output unchanged
;if this output from application has msgName string
logger = default stdio
logger = secondlogger stdio
log-route = secondlogger msgName
log-route = default ^((?!msgName).)*$
log-encoder = json:default {"@timestamp":"${strftime:%%Y-%%m-%%dT%%H:%%M:%%S.666Z}","source":"uwsgi", "message":"${msg}"}
log-encoder = format:secondlogger ${msg}
log-encoder = nl
logger-req = stdio
log-req-encoder = json {"@timestamp":"${strftime:%%Y-%%m-%%dT%%H:%%M:%%S.666Z}","source":"req", "message":"${msg}"}
log-req-encoder = nl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment