Logging Framework

A logger with levels, formatters, and multiple pluggable output sinks.

Easy35 minChain of ResponsibilitySingletonAsync sinks

Design a logging library like a simplified version of Python's logging or Log4j: callers log messages at levels, and the framework filters, formats, and writes them to one or more destinations. It tests pattern fluency (Chain of Responsibility, Strategy, Singleton) and non-blocking I/O thinking.

Requirements

Functional

  • Log levels: DEBUG < INFO < WARN < ERROR < FATAL; each logger has a minimum level.
  • logger.info("msg", **context) creates a record with timestamp, level, logger name, message, and context.
  • Multiple sinks (appenders): console, file, remote HTTP endpoint; each sink can have its own level and formatter.
  • Pluggable formatters: plain text, JSON.
  • Named, hierarchical loggers (app.payments inherits config from app).
  • Configuration at startup (code or dict).

Non-functional

  • Logging must never crash the application, and should add minimal latency to the caller.
  • Thread-safe: many threads log concurrently without interleaved lines.
  • Ordering preserved per sink.
  • Extensible: new sinks and formatters without modifying core classes.

Try it first

Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.

35:00

Complete & continue

Defend it out loud

The AI interviewer will probe your design for Logging Framework and score it.

Mock interview