Skip to content

Commit c91eddb

Browse files
committed
configuration: Add section regarding JSON formatted access logs
Signed-off-by: Andrew Clayton <[email protected]>
1 parent 19202a7 commit c91eddb

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

source/configuration/index.rst

+26-1
Original file line numberDiff line numberDiff line change
@@ -5679,6 +5679,31 @@ to define the log format:
56795679
}
56805680
}
56815681
5682+
===============
5683+
JSON log format
5684+
===============
5685+
5686+
Starting with NGINX Unit 1.34.0, `format` can instead be an object describing
5687+
JSON field name/value pairs, e.g.,
5688+
5689+
.. code-block:: json
5690+
5691+
{
5692+
"access_log": {
5693+
"path": "/tmp/access.log",
5694+
"format": {
5695+
"remote_addr": "$remote_addr",
5696+
"time_local": "$time_local",
5697+
"request_line": "$request_line",
5698+
"status": "$status",
5699+
"body_bytes_sent": "$body_bytes_sent",
5700+
"header_referer": "$header_referer",
5701+
"header_user_agent": "$header_user_agent"
5702+
}
5703+
}
5704+
}
5705+
5706+
The JSON *values* support being strings, variables and JavaScript.
56825707
56835708
======================
56845709
Conditional access log
@@ -5738,4 +5763,4 @@ Example with njs and the use of a template literal:
57385763
"if": "`${uri == '/health' ? false : true}`",
57395764
"path": "..."
57405765
}
5741-
}
5766+
}

0 commit comments

Comments
 (0)