Course contentsShow
← Software Engineering
Lesson 1128 of 1,93334. Logging and ObservabilityFree lesson

Logging in Local Development

Configuring different log levels and outputs for development versus production environments for effective debugging.

Logging in Local Development

You'll learn how to configure logs differently for local debugging versus production environments to maximize visibility when coding without overwhelming logs in live systems.

Why Local Logging is Different

When you're developing on your laptop, you want maximum visibility into what's happening. Think of it like turning on all the lights in a workshop versus a finished museum exhibit—one is for work, the other for display.

In local development, you typically want:

  • Lower thresholds: Set your minimum log level to DEBUG or even TRACE to see everything
  • Verbose output: Include stack traces, variable values, timing information
  • Console output: Logs printed directly to your terminal where you can see them immediately
  • Synchronous writing: Don't buffer logs; write them instantly so if your app crashes, you see what happened
  • Pretty formatting: Colors, indentation, human-readable timestamps

In production, you reverse almost all of this—INFO or WARN minimum level, structured JSON format, asynchronous writes to remote aggregators, minimal detail to protect performance and privacy.

Configuration Strategy

Most logging frameworks let you configure different behaviors per environment using config files or environment variables. You might have a logging.dev.conf that sets level=DEBUG, output=console and a logging.prod.conf with level=WARN, output=json-file.

The key is making this switch automatic based on environment detection—your app should "know" it's running locally and adjust accordingly, not require manual changes.

The Balance

Even in local development, don't log everything—you'll drown in noise. Use DEBUG for detailed flow, INFO for major milestones you always want to see, and keep performance-critical loops clean unless actively debugging them.

Key Takeaway: Configure local development logging to be verbose, immediate, and human-readable, while production logging should be structured, filtered, and performance-conscious—your logging framework should handle this environment-based switching automatically.