- Recorded requests — every request received since MockServer last started or was reset
- Active expectations — all currently registered expectations
- Recorded expectations — expectations captured from proxied traffic
- Logs — all internal log events
Log levels
The log level controls how much detail MockServer records. Set it using themockserver.logLevel property or MOCKSERVER_LOG_LEVEL environment variable.
| Level | What it includes |
|---|---|
TRACE | Low-level details, full request/response content, and verbose matcher internals. Generates a large volume of output. |
DEBUG | All matcher results including which specific matchers failed (e.g. a particular header value mismatch). Useful when debugging why a request is not matching. |
INFO | All interactions: expectations created, requests matched, expectations cleared, verifications run. (Default) |
WARN | Exceptions and errors only. |
ERROR | Critical errors only. |
OFF | No logging. |
Retrieving recorded requests
Retrieve all requests MockServer has received since it last started or was reset:Retrieving active expectations
Retrieve all currently registered expectations:Retrieving recorded logs
Retrieve the log messages MockServer has recorded:Clearing state
Clear state selectively using thetype parameter. This is useful between tests to remove expectations or logs without fully resetting MockServer.
| Type | What is cleared |
|---|---|
all | Recorded requests, active expectations, recorded expectations, and logs |
log | Recorded requests and log entries only |
expectations | Active and recorded expectations only |
Clear all state matching a request path
Clear only logs for a specific path
Clear only expectations for a specific path
When
logLevel is set to DEBUG, clear operations mark log entries as deleted rather than removing them. This keeps the UI’s log history intact so you can still debug interactions that occurred before the clear.Resetting all state
Reset removes all recorded requests, all active expectations, all recorded expectations, and all logs:Persisting expectations
By default, expectations exist only in memory and are lost when MockServer restarts. Enable persistence to write expectations to a JSON file that MockServer reloads on startup.Enable persistence
MockServer updates the persistence file automatically whenever expectations are added, cleared, or expire. To watch the initialization file for external changes and reload expectations without restarting: