← Workflows

阅读中文版本

Log Level Configuration Workflow

Configure application log levels for different environments to balance observability and performance.

beginner~15 minloggingconfigurationworkflow

Objective

Set appropriate log levels for development, staging, and production environments.

Environment

  • An application with a logging framework configured
  • Environment variable support for log level
  • A configuration file or startup script

Steps

1. Set development level

Configure DEBUG level for local development to see all log messages.

Expected state: Development environment shows DEBUG and above.

2. Set staging level

Configure INFO level for staging to monitor without excessive output.

Expected state: Staging environment shows INFO and above.

3. Set production level

Configure WARN level for production to reduce volume and cost.

Expected state: Production environment shows WARN and above.

4. Verify each environment

Start the application in each environment and confirm the log output level.

Expected state: Each environment logs at the configured level.

Decision points

Should production use ERROR only?

  • Yes, for minimal output
  • No, WARN is better for visibility

Use WARN in production; ERROR alone misses important warnings that need investigation.

Expected outcome

Each environment has an appropriate log level configured and verified.

Verification

Start the application in each environment and confirm the log output matches the configured level.

Cleanup

No cleanup needed; log configuration should be committed.

Right level for the right environment

Too much logging in production costs money and hides important signals. Too little logging makes debugging impossible.

LOG_LEVEL=debug npm start  # development
LOG_LEVEL=warn npm start   # production

Implementation Notes

This workflow provides a structured approach to ensure consistent results across team members and environments.

Common Pitfalls

Skipping verification steps or rushing through the process can lead to incomplete results. Always follow each step in order and verify before proceeding.