A request id threaded through one request (SPEC §6): on the request as
:wb/request-id, on the response as X-Request-Id, in the SLF4J MDC as
request-id for the duration, and in one access line. The base ships no
logging backend — a library must not — so the line goes through
tools.logging and the MDC key reaches whatever pattern the host configures
(%X{request-id} in logback).
An incoming X-Request-Id is not trusted: a client could then choose what
the logs say. Behind a proxy that assigns ids, the host maps them.
A request id threaded through one request (SPEC §6): on the request as
`:wb/request-id`, on the response as `X-Request-Id`, in the SLF4J MDC as
`request-id` for the duration, and in one access line. The base ships no
logging backend — a library must not — so the line goes through
tools.logging and the MDC key reaches whatever pattern the host configures
(`%X{request-id}` in logback).
An incoming `X-Request-Id` is not trusted: a client could then choose what
the logs say. Behind a proxy that assigns ids, the host maps them.(path-of request)The path every log line of the base shows for request: the access line's, so a
path that carries a secret is hidden from an error's datum as well as from it.
The path every log line of the base shows for `request`: the access line's, so a path that carries a secret is hidden from an error's datum as well as from it.
(wrap-request-id handler)(wrap-request-id handler logged-path)The outermost middleware: every response, including a 404 or a static asset, carries the id. If the handler throws, the access line still goes out with a 500 and the throwable propagates; the MDC is cleared either way.
logged-path answers what the line shows for a request's path — its :uri unless
given. It is asked of the request as it arrived and kept on it as
:wb/logged-path, so what it hides stays hidden from every line of the base,
and when an inner layer throws.
The outermost middleware: every response, including a 404 or a static asset, carries the id. If the handler throws, the access line still goes out with a 500 and the throwable propagates; the MDC is cleared either way. `logged-path` answers what the line shows for a request's path — its `:uri` unless given. It is asked of the request as it arrived and kept on it as `:wb/logged-path`, so what it hides stays hidden from every line of the base, and when an inner layer throws.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |