access_log
Logs structured access records for each request and response.
On this page
Logs structured access records for each request and response.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
sample_rate | number | no | Fraction of requests to log (0.0, 1.0]. Defaults to 1.0. |
fields | any[] | no | Scalar field tokens; replaces the default ten when present. Mutually exclusive with template. |
request_headers | string[] | no | Request header names allowed for request_header.<name> tokens. |
response_headers | string[] | no | Response header names allowed for response_header.<name> tokens. |
conditions | AccessLogEmitConditions | no | Emit-time conditions (AND across keys). |
conditions.min_duration_ms | integer | no | |
conditions.status_classes | (1xx | 2xx | 3xx | 4xx | 5xx)[] | no | |
conditions.paths | string[] | no | |
template | string | no | Text template with {field} placeholders. The rendered string is logged as the line field of the access event, and PRAXIS_LOG_FORMAT still decides text or JSON output. Mutually exclusive with fields. |
sink | SinkConfig | no | Output sink: {type: stdout}, {type: file, path: ...}, or (with the access-log-syslog feature) {type: syslog, ...}. Omitted means emit through the tracing subscriber. |
sink.type | stdout | file | syslog | yes | Sink kind (stdout, file, or syslog with the access-log-syslog feature). |
sink.path | string | no | File path; required for file, rejected for stdout. Doubles as the local socket path override for syslog + transport: unix. |
sink.transport | unix | udp | tcp | no | Syslog transport. Only valid for type: syslog; defaults to unix. |
sink.address | string | no | Remote host:port for syslog with transport: udp/tcp. |
sink.facility | kern | user | mail | daemon | auth | syslog | lpr | news | uucp | cron | authpriv | ftp | local0 | local1 | local2 | local3 | local4 | local5 | local6 | local7 | no | Syslog facility. Only valid for type: syslog; defaults to user. |
Examples
Example 1
filter: access_log
sample_rate: 0.1 # optional; log ~10% of requests (default 1.0)
fields: # optional; replaces default ten fields when present
- method
- path
- status
- duration_ms
- request_header.user-agent
- trace_id
request_headers: [user-agent] # optional; pairs with request_header.* tokens
response_headers: [content-type]
conditions: # optional emit-time gates (AND across keys)
min_duration_ms: 1000
status_classes: [4xx, 5xx] # OR within list
paths: ["/api"] # OR within list; segment-boundary prefixes
sink: # optional; default emits via the subscriber
type: file # `stdout` or `file`
path: /var/log/praxis/access.log # required for `file`, rejected for `stdout`
Example 2
filter: access_log
# Mutually exclusive with `fields`; quote client-controlled tokens.
template: '{method} {path} [{status}] {duration_ms}ms ua="{request_header.user-agent}"'
request_headers: [user-agent]