- 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.
Change the log level at runtime without restarting MockServer:
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.
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
1
Set the persistence properties
2
Confirm the file is reused on restart
Set
persistedExpectationsPath and initializationJsonPath to the same file so MockServer both writes to and reads from the same location. On each restart, MockServer loads expectations from this file before accepting requests.