HTTP directives
log_format directive (HTTP)
HTTP context only. Built-in combined format exists; escape=json since 1.11.8; none since 1.13.10. Define a format before selecting it. Escaping is not redaction.
Formal Syntax & Structure
nginx syntaxnginx
log_format name [escape=default|json|none] string ...;Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Format identifier |
| escape | string | Variable escaping mode |
| string | string | One or more template fragments |
Working Example
Example Snippetnginx
log_format lab_json escape=json '{"id":"$request_id","site":"$server_name",' '"method":"$request_method","uri":"$uri",' '"status":"$status","seconds":"$request_time",' '"upstream":"$upstream_status"}';