access_log

Logs structured access records for each request and response.
On this page

Logs structured access records for each request and response.

Configuration

FieldTypeRequiredDescription
sample_ratenumbernoFraction of requests to log (0.0, 1.0]. Defaults to 1.0.
fieldsany[]noScalar field tokens; replaces the default ten when present. Mutually exclusive with template.
request_headersstring[]noRequest header names allowed for request_header.<name> tokens.
response_headersstring[]noResponse header names allowed for response_header.<name> tokens.
conditionsAccessLogEmitConditionsnoEmit-time conditions (AND across keys).
conditions.min_duration_msintegerno
conditions.status_classes(1xx | 2xx | 3xx | 4xx | 5xx)[]no
conditions.pathsstring[]no
templatestringnoText 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.
sinkSinkConfignoOutput sink: {type: stdout}, {type: file, path: ...}, or (with the access-log-syslog feature) {type: syslog, ...}. Omitted means emit through the tracing subscriber.
sink.typestdout | file | syslogyesSink kind (stdout, file, or syslog with the access-log-syslog feature).
sink.pathstringnoFile path; required for file, rejected for stdout. Doubles as the local socket path override for syslog + transport: unix.
sink.transportunix | udp | tcpnoSyslog transport. Only valid for type: syslog; defaults to unix.
sink.addressstringnoRemote host:port for syslog with transport: udp/tcp.
sink.facilitykern | user | mail | daemon | auth | syslog | lpr | news | uucp | cron | authpriv | ftp | local0 | local1 | local2 | local3 | local4 | local5 | local6 | local7noSyslog 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]