When something breaks in production, the first instinct is to add console.log statements everywhere, redeploy, and wait for the error to happen again. That is not debugging. That is guessing with extra steps.
Logging and debugging are different tools for different jobs. Confusing them makes problems harder to find, not easier.
What debugging actually is
Debugging is the process of finding the root cause of a bug. You reproduce the issue, inspect the program state, trace the execution, and identify exactly where the logic went wrong. A debugger lets you pause execution, examine variables, and step through code line by line.
Logging is just recording what happened. It does not find the bug for you. It gives you breadcrumbs.
Why console.log everywhere fails
Adding print statements to every function creates noise, not signal. In production, you get flooded with output. You cannot tell which log line matters. Worse, you often forget to remove them, shipping debugging code to real users.
If the bug does not happen while you are watching, your logs do not help. You have to reproduce it, add more logs, redeploy, and wait again. That is a slow, expensive loop.
What good logging looks like
Good logging answers three questions without requiring a redeploy:
- What happened?
- When did it happen?
- Which request, user, or input triggered it?
Use structured logging — JSON output with fields like level, timestamp, service, request_id, and message. This makes logs searchable and filterable.
Example of a bad log:
User logged in
Value is 42
Error happened
Example of a good log:
{"level":"error","timestamp":"2026-01-15T10:32:01Z","service":"auth","request_id":"abc123","message":"login failed","reason":"invalid credentials","user_id":null}
When to use each
| Situation | Tool |
|---|---|
| Reproducing a bug locally | Debugger / breakpoints |
| Understanding production failures | Structured logs |
| Tracking request flow across services | Correlation IDs in logs |
| Quick check during development | Console.log (temporary) |
The rule
Debug locally with a debugger. Monitor production with logs. Do not use logs to debug locally, and do not rely on a debugger in production.
Console.log is a crutch. Logging is infrastructure.

Leave a Reply