Set a project's logging and templating
Before you begin
- Role
- Admin or higher.
A project’s Responses and logging settings decide whether its mocks can use templates, and what MockHub keeps about the requests the project answers. What each logging setting stores, and for how long, is described in Your data in MockHub.
The gateway mode and upstream are set on the project’s Captures tab, which Open Captures under Recording from a real API leads to; see Record traffic from a real API.
Browser access (CORS), in the same section, decides which web pages may read the project’s answers; see Let web pages call a project.
-
Open the project’s Settings tab.
-
Go to Responses and logging.
-
Turn on or off the switches you want to change, using the table below.
-
To redact a header, type its name into Request headers to redact or Response headers to redact, and press Enter.
-
Select Save settings.
| To | Change |
|---|---|
| Keep personal data in requests out of the logs | Turn off Log request headers and body. The method, path, time and caller’s IP address are still stored. |
| Keep one request header’s value out of the logs | Add its name, such as X-Api-Key, to Request headers to redact. |
| Keep cookies a mock sets out of the logs | A new project redacts Set-Cookie already. On an older one, add it to Response headers to redact. |
| Keep requests no mock answered out of the logs | Turn off Log requests no mock answered, which a new project has on. |
| Stop storing new traffic, while still answering it | Turn off Store request logs. |
Send {{…}} in response bodies and headers exactly as written |
Turn off Response templating. |
To keep a field, such as customerRef, out of captures, inbox posts and what an AI model is sent, type its name into Body keys to redact in captures in the same section and press Enter. It applies whatever the logging switches say.
Response templating
Section titled “Response templating”With Response templating on, which is the default, a mock’s body and headers can contain Handlebars expressions such as {{request.path}}, and fake data from random. MockHub evaluates them each time the mock answers; see Write dynamic responses with templates.
Turned off, every mock in the project answers with its body and headers exactly as written, braces included. Turn it off when a body legitimately contains {{, such as a template meant for another system. The setting applies to all the project’s mocks together.
Redacted headers
Section titled “Redacted headers”A redacted header is stored in the request log with its value replaced:
| Header | Stored as |
|---|---|
Authorization |
The scheme is kept: Bearer [REDACTED] |
Cookie |
The cookie names are kept: session_id=[REDACTED] |
| Any other | [REDACTED] |
Names are compared ignoring case. Authorization and Cookie are on the request list of a new project.
Each redaction list appears only while its switch is on: Log request headers and body for request headers, Log response headers and body for response headers. Turning the switch off empties its list when you save, so add the names again if you turn it back on.
Result
Section titled “Result”MockHub shows Settings saved. The settings apply from the next request: templating changes what every mock answers, and the logging settings change what is stored from then on.
Limits
Section titled “Limits”- Changing these settings needs the Admin role. An Editor sees them with “Changing these needs the Admin role in this workspace.” and can still rename the project under Project details.
- Settings apply to the whole project; a single mock cannot log differently.
- Saving does not change logs already stored. To remove them, delete request logs.
- Redaction changes only what is stored. Your mocks still see the real header when they match a request.
- Body fields are redacted by name only in captures, inbox posts and requests the gateway answered with its own
502,500or503, under Body keys to redact in captures; Captures says which bodies and fields that covers. The body of a request a mock answered, or no mock matched, is stored as it was sent, unless Log request headers and body is off.