Logging
ELI5 — The Vibe Check
Logging is writing a diary for your program. Every time something important happens — a user logs in, an error occurs, a payment is processed — you write it down with a timestamp. When something breaks at 3am, the logs are your only witness to what happened.
Real Talk
Logging is the practice of recording events, errors, and diagnostic information during program execution. Logs are structured with levels (DEBUG, INFO, WARN, ERROR, FATAL) to filter by severity. Production systems send logs to centralized services (Datadog, Loki, CloudWatch) for search, alerting, and analysis. Structured logging (JSON format) is preferred over plain text for machine parsing.
Show Me The Code
// Basic console logging (development):
console.log('User logged in:', userId);
console.error('Payment failed:', error);
// Structured logging with a library (production):
import logger from './logger'; // e.g. pino, winston
logger.info({ userId, action: 'login' }, 'User authenticated');
logger.error({ error, orderId }, 'Payment processing failed');
When You'll Hear This
"Check the logs for the error." / "Add a log statement before the API call so we can trace it."
Related Terms
Debug
Debugging is the process of finding and fixing the gremlins in your code. Something is broken, and you need to play detective — adding clues (console.
Error Handling
Error handling is the art of planning for things to go wrong and dealing with them gracefully instead of letting everything catch fire.
Monitoring
Monitoring is keeping a constant eye on your app while it runs — tracking whether it's up, how fast it responds, how many errors it throws, and how much me...
Stack Trace
A stack trace is the error report that tells you exactly which functions were called right before your code crashed.