Skip to content

Commit

Permalink
configuration: Add section regarding JSON formatted access logs
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Clayton <[email protected]>
  • Loading branch information
ac000 committed Dec 17, 2024
1 parent 19202a7 commit 3a3ead8
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion source/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5679,6 +5679,31 @@ to define the log format:
}
}
===============
JSON log format
===============
Starting with NGINX Unit 1.34.0, **format** can instead be an object
describing JSON field name/value pairs, e.g.,
.. code-block:: json
{
"access_log": {
"path": "/tmp/access.log",
"format": {
"remote_addr": "$remote_addr",
"time_local": "$time_local",
"request_line": "$request_line",
"status": "$status",
"body_bytes_sent": "$body_bytes_sent",
"header_referer": "$header_referer",
"header_user_agent": "$header_user_agent"
}
}
}
The JSON *values* support being strings, variables and JavaScript.
======================
Conditional access log
Expand Down Expand Up @@ -5738,4 +5763,4 @@ Example with njs and the use of a template literal:
"if": "`${uri == '/health' ? false : true}`",
"path": "..."
}
}
}

0 comments on commit 3a3ead8

Please sign in to comment.