Access Log File Sink

Writes NDJSON access log records directly to a file, bypassing the tracing subscriber

Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.

Category: Practical
Task: Writes NDJSON access log records directly to a file, bypassing the tracing subscriber

Prerequisites: The product runtime and any backend services referenced by this configuration.

This configuration comes from the selected release. The example has not been run here; external services are not bundled.

Download the source file.

# Access Log File Sink
#
# Writes NDJSON access log records directly to a file, bypassing the
# tracing subscriber. The file is opened in append+create mode at
# startup and the handle is retained, so rename-based rotation keeps
# writing to the rotated file; restart the proxy to reopen. logrotate's
# copytruncate works without a reopen but can lose records written
# between the copy and the truncate.
#
# Usage:
#   cargo run -p praxis-proxy -- -c examples/configs/observability/access-log-file-sink.yaml
#   curl http://localhost:8080/
#   tail -f /tmp/praxis-access.log

listeners:
  - name: default
    address: "127.0.0.1:8080"
    filter_chains:
      - main

filter_chains:
  - name: main
    filters:
      - filter: request_id

      - filter: access_log
        fields:
          - method
          - path
          - status
          - duration_ms
          - request_id
        sink:
          type: file
          path: /tmp/praxis-access.log

      - filter: router
        routes:
          - path_prefix: "/"
            cluster: backend

      - filter: load_balancer
        clusters:
          - name: backend
            endpoints:
              - "127.0.0.1:3000"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends