Skip to content

Access Logger ​

Sword can log one line per request once the response is sent: method, uri, status, latency and a truncated request id. This is separate from the global [tracing] subscriber and is driven entirely by the [web.logger] section.

The logger is off unless the section is present.

Configuration ​

toml
[web.logger]
enabled = true
level = "auto"
skip-paths = ["/api/health"]
log-query = false
KeyTypeDefaultDescription
enabledbooltrueEnables or disables the logger
levelauto | infoautoLog level policy. See Levels
skip-pathsString[][]Paths to exclude from logging (exact or prefix match)
log-queryboolfalseInclude the query string in the logged uri

Levels ​

  • info logs every request at INFO regardless of the status.
  • auto picks the level from the response status:
StatusLevel
2xx / 3xxINFO
4xxWARN
5xxERROR

Request ID ​

The logger reuses the x-request-id header set by the built-in RequestIdLayer. When present, the logger logs only the first 8 characters; otherwise it uses a - placeholder.