Logging
logging console.log serverless functions invocation ID request tracing debuggingNhost Functions support logging through standard console methods in Node.js. Use console.log(), console.warn(), and console.error() to log messages during function execution. All logs are captured and displayed in the logs page page with metadata about each invocation.
Log Format
Section titled “Log Format”Each log entry includes:
| Field | Description |
|---|---|
log | The actual log message |
path | The function path that generated the log |
invocationId | Unique identifier for this function invocation |
level | Log level: INFO, WARN, or ERROR |
Example log entry:
{ "log": "This was logged with console.log", "path": "/function", "invocationId": "cb1835df-a5e6-440b-ab59-e2e2f563c176", "level": "INFO"}Execution Metrics
Section titled “Execution Metrics”Each function execution also generates a metrics log entry with performance data:
{ "path": "/function", "invocationId": "cb1835df-a5e6-440b-ab59-e2e2f563c176", "status": "success", "metrics": { "durationMs": 11.067, "producedBytes": 718 }, "spans": [ { "name": "responseLatency", "durationMs": 9.913, "start": "2026-01-10T11:38:03.850Z" }, { "name": "responseDuration", "durationMs": 0.057, "start": "2026-01-10T11:38:03.860Z" }, { "name": "runtimeOverhead", "durationMs": 1.023, "start": "2026-01-10T11:38:03.860Z" } ]}Correlating Logs
Section titled “Correlating Logs”Invocation ID
Section titled “Invocation ID”The invocationId is unique to each function invocation and helps correlate all logs from the same execution. Access it in your code via:
req.invocationIdRequest ID
Section titled “Request ID”You can pass a custom x-request-id header from the client for tracing requests across services:
req.headers['x-request-id']If not provided, a unique request ID is generated automatically.