Skip to content
Learn Netverks

Lesson

Step 29/36 81% through track

debugging-logging

Debugging and logging

Last reviewed May 28, 2026 Content v20260528
Track mode
nodejs_server
Means
Node sandbox
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Debugging and logging: the syntax, APIs, and habits you need before advancing in Node.js.

Teams ship Debugging and logging on every Node.js codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Debugging and logging in contexts like: REST/GraphQL APIs, BFF layers, CLIs, webhooks, and real-time services (with WebSockets).

Run JavaScript on the Node runner when configured—never mix arbitrary shell commands in lessons.

When you can explain the previous lesson's ideas without copying starter code.

Production Node apps need structured logs and reproducible debugging—not scattered console.log. Learn levels, correlation IDs, and the built-in debugger.

Logging levels

  • error — failures requiring attention
  • warn — degraded but running
  • info — request milestones, startup
  • debug — verbose dev-only detail

Structured JSON logs

logger.info({ reqId, method, url, ms }, 'request completed');

Tools like Datadog, CloudWatch, and Loki parse JSON fields for search and alerts.

Debugging

  • node --inspect — Chrome DevTools debugger
  • VS Code launch.json — breakpoints in handlers
  • Reproduce with fixed NODE_ENV and env vars

Important interview questions and answers

  1. Q: console.log in production?
    A: Acceptable for small apps; structured loggers (pino) add levels, redaction, and performance.
  2. Q: Correlation ID?
    A: Unique per request propagated through logs—trace one user action across microservices.

Self-check

  1. Why log as JSON in production?
  2. What flag enables Node inspector?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Structured logs why?
  • DEBUG env pattern?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump