Spec0docs
Mock serverHow-to

Request Logs

The mock server records every incoming request and the response it returned. Logs are available in the **Logs** tab of each mock server and via the REST API.

The mock server records every incoming request and the response it returned. Logs are available in the Logs tab of each mock server and via the REST API.


What is captured

Each log entry contains:

FieldDescription
operationIdThe OpenAPI operation that was matched
httpMethodHTTP method of the request
requestPathPath from the incoming request
requestHeadersAll request headers
requestBodyThe request body (if present)
responseStatusCodeStatus code that was returned
responseHeadersAll response headers (including X-spec0-* diagnostic headers)
responseBodyResponse body that was returned
variantIdUUID of the variant that was selected
responseTimeMsTime taken to produce the response, in milliseconds
clientIpIP address of the caller
userAgentUser-Agent header from the caller
createdAtTimestamp of the request (ISO 8601)

Viewing logs in the UI

  1. Open a mock server and go to the Logs tab.
  2. The most recent requests appear at the top, newest first.
  3. Scroll down to load older entries (infinite scroll, 20 entries per page).
  4. Click any row to expand it and inspect the full request and response, including headers and body.

Querying logs via API

# Get the 50 most recent log entries
curl http://localhost:8080/mock-server/servers/{mockServerId}/logs?limit=50

The response is an array of log objects sorted by createdAt descending.


Diagnostic response headers

Every mock response includes these headers, which also appear in the log:

HeaderValue
X-spec0-Mock-Responsetrue
X-spec0-Mock-Variant-IdUUID of the selected variant
X-spec0-Mock-Operation-IdResolved operationId

[!TIP] Use X-spec0-Mock-Variant-Id in your test assertions to verify that the expected variant was served for a given request.


Log retention

The number of log entries retained per mock server is controlled by the maxLogEntries configuration field. Once the limit is reached, older entries are dropped.

curl -X PATCH http://localhost:8080/mock-server/servers/{mockServerId}/config \
  -H 'Content-Type: application/json' \
  -d '{"maxLogEntries": 500}'

See also

On this page