How to Debug n8n Webhook Issues with Logs

Step by Step Guide to Debug n8n Webhook Issues with Logs

 


 

Who this is for: n8n developers and ops engineers who need to troubleshoot failing webhooks in self‑hosted or cloud instances. We cover this in detail in the n8n Webhook Errors.


Quick Diagnosis (Featured Snippet)

  1. Enable Debug logging – Settings → Execution → Log Level → Debug (or set N8N_LOG_LEVEL=debug).
  2. Trigger the webhook and open Settings → Execution → Execution List → click the run → View Full Log.
  3. Add a Function node with console.log(JSON.stringify($json, null, 2)) for payload inspection.
  4. Ship logs to an external system (Loki, Papertrail) and mask secrets before sending.

Result: Full request/response details, node I/O, and error stacks appear in the log, letting you pinpoint the failure.


1. Why n8n’s Built‑in Logs Are Your First‑Line Debugger

If you encounter any payload size limit resolve them before continuing with the setup.

Log Level What You See When to Use
Error Only error stack traces Production, minimal noise
Warn Errors + warnings (e.g., missing headers) Stable environments
Info Workflow start/finish, node names General monitoring
Debug Full HTTP request/response, node input/output, internal timings Debugging webhooks, API integrations
Trace Extremely verbose (internal library calls) Rare, for n8n core developers

EEFA note: Debug adds ~30 % overhead on high‑throughput instances. Enable it only while troubleshooting, then revert to Info or Warn.


2. Enabling Debug Logging

If you encounter any migration and version changes resolve them before continuing with the setup.

2.1 Self‑hosted (Docker)

docker run -e N8N_LOG_LEVEL=debug -p 5678:5678 n8nio/n8n

2.2 Self‑hosted (npm / binary)

# Linux/macOS
export N8N_LOG_LEVEL=debug
n8n start
:: Windows CMD
set N8N_LOG_LEVEL=debug
n8n start

2.3 Cloud (n8n.io)

Open Settings → Execution → Log Level and select Debug.

EEFA: Do not commit the N8N_LOG_LEVEL=debug env var to your CI/CD pipeline for production builds.


3. Accessing the Full Execution Log

  1. Settings → Execution → Execution List.
  2. Filter by Webhook and locate the relevant run.
  3. Click View Full Log – a modal shows a timestamp‑ordered, colour‑coded dump.

Tip: Use the Search box (Ctrl+F) to locate Incoming Request or Error: quickly.

Example Log Snippet (Debug)

[2025-12-31 14:22:07.123] DEBUG - Incoming Request: POST /webhook/my-workflow
Headers: {"content-type":"application/json","x-n8n-signature":"sha256=..."}
Body: {"event":"order.created","orderId":12345}
[2025-12-31 14:22:07.129] DEBUG - Node "Set" input: {"event":"order.created","orderId":12345}
[2025-12-31 14:22:07.135] ERROR - Node "HTTP Request" failed: 404 Not Found (https://api.example.com/orders/12345)

4. Adding Custom Console Logs Inside Workflows

When the built‑in log isn’t granular enough, insert a Function node at the point you want to inspect.

// Log the raw webhook payload (redact secrets first)
console.log('--- WEBHOOK PAYLOAD START ---');
console.log(JSON.stringify($json, null, 2));
console.log('--- WEBHOOK PAYLOAD END ---');
return $json;

Redacting Sensitive Fields

const safe = { ...$json, token: '[REDACTED]' };
console.log(JSON.stringify(safe));

EEFA warning: Never log raw authentication tokens or passwords. Always mask them before printing.


5. Using the “Log” Node for Structured Output

The Log node (v1.3+) writes a JSON line to the same log stream and lets you set a custom level.

Field Value
Message Any string (e.g., “Order ID received: {{ $json.orderId }}”)
Level debug / info / warn / error

Workflow snippet:

  1. Webhook →
  2. Log (Message: Incoming order {{ $json.orderId }}, Level: debug) →
  3. …rest of workflow

The Log node’s output appears in the View Full Log view, making correlation trivial.


6. Shipping n8n Logs to an External Aggregator

6.1 Loki (Grafana)

Add the Loki output variables to your Docker compose:

services:
  n8n:
    image: n8nio/n8n
    environment:
      - N8N_LOG_LEVEL=debug
      - N8N_LOG_OUTPUT=loki
      - N8N_LOG_LOKI_URL=http://loki:3100/loki/api/v1/push

6.2 Papertrail (Syslog)

Run the container with syslog configuration:

docker run -e N8N_LOG_OUTPUT=syslog \
           -e N8N_LOG_SYSLOG_HOST=logs.papertrailapp.com \
           -e N8N_LOG_SYSLOG_PORT=12345 \
           n8nio/n8n

EEFA: Ensure the syslog destination does not store raw request bodies containing PII unless you have compliance approval.


7. Common Debug Patterns & Resolutions

Symptom Log Indicator Typical Cause Fix
404 Not Found from downstream API HTTP Request node error → 404 Wrong URL or missing path parameter Verify $json values used in URL; add a Set node to construct the URL explicitly.
Signature verification fails Error: Invalid signature in webhook log Mismatch between n8n’s secret and sender’s HMAC Re‑enter the secret in Webhook → Authentication → Signature; mask secret in logs.
Payload is empty Body: {} in Incoming Request Sender omitted Content‑Type: application/json or used GET instead of POST Add a Set node to default missing fields; ask the caller to send proper headers.
Timeout after 30 s Execution timed out Long‑running external API call Increase Webhook Timeout in node settings or split workflow using Queue node.
Sensitive data appears in logs token: abc123 printed in Debug log Direct console.log($json) without redaction Use the masking snippet from §4 before logging.

8. Checklist – “Is My Debug Logging Ready?”

  • Log level set to Debug (or Info for production).
  • Sensitive fields are redacted (token, password, apiKey).
  • Execution logs are accessible via UI or external aggregator.
  • Custom Function or Log nodes added at critical junctions.
  • Log rotation / retention policy configured (e.g., Docker --log-opt max-size=10m).
  • Monitoring alerts (e.g., Loki alerts on error level) are in place.

10. Next Steps

  • Automate log alerts: Set up a Loki alert rule for level="error" on webhook executions.
  • Secure log storage: Enable encryption at rest for your log destination (e.g., Loki’s TLS).
  • Performance tuning: After fixing the issue, downgrade the log level back to Info to restore normal throughput.

Conclusion

By enabling Debug logging, inspecting the full execution log, and optionally inserting targeted console.log statements, you gain complete visibility into every webhook request, header, payload, and node execution. Shipping logs to a centralized aggregator keeps history alive and lets you set alerts for future failures, while redaction safeguards sensitive data. Follow the checklist to keep your production instance observable, secure, and performant.

Leave a Comment

Your email address will not be published. Required fields are marked *