Opened 8 years ago

Closed 6 years ago

#1068 closed enhancement (fixed)

Support JSON log format

Reported by: dimaqq@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.11.x
Keywords: Cc:
uname -a: Linux (docker) 4.7.2-1-ARCH #1 SMP PREEMPT Sat Aug 20 23:02:56 CEST 2016 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.11.1
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled

Description

I'm trying to set up complex system, which uses a log aggregator (at the moment fluentd).

Obv., logs could be parsed, but that's hacky and impacts upgrade path.

There's a hack to manually format nginx access.log as JSON (log_format le_json '{"time":"$time_iso8601", ...) but it's not good enough.

Nginx can only (?) log entire request string, and it escapes this data.

Nginx uses \x?? escape sequences, while JSON only supports \u????.

For the time being I have to use apache instead :(

Change History (2)

comment:1 by Maxim Dounin, 8 years ago

We've consider this. Right now you may want to take a look at a 3rd party JSON log module as available from https://github.com/jiaz/nginx-http-json-log (not tested it myself though).

Version 0, edited 8 years ago by Maxim Dounin (next)

comment:2 by Maxim Dounin, 6 years ago

Resolution: fixed
Status: newclosed

Starting with nginx 1.11.8 (0cf4e82e7c48), the escape=json parameter of the log_format directive can be used to generate properly escaped JSON logs.

Note: See TracTickets for help on using tickets.