Skip to content

Instantly share code, notes, and snippets.

@amgorb
Created April 11, 2018 16:37
Show Gist options
  • Save amgorb/2f8a834f7f1c400c50a8b616f4391117 to your computer and use it in GitHub Desktop.
Save amgorb/2f8a834f7f1c400c50a8b616f4391117 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