Phase 1: Requirements & Use Cases
Interviewer: "Design a logging framework."
Candidate: "Let me clarify scope. I'm designing an in-process logging library — something like Log4j or Python's
loggingmodule — that application code can use to emit log messages at different severity levels, filtered and routed to one or more output destinations like console, file, or a remote endpoint. I'm not designing a distributed log aggregation system like ELK or Splunk. Does that match your intent?"Interviewer: "Yes. What are the core use cases?"
Candidate: "Core use cases:
- Application code logs a message at a severity level (DEBUG, INFO, WARN, ERROR, FATAL)
- Log messages are filtered by minimum level — DEBUG messages don't appear in production
- Log messages are routed to one or more appenders (console, file, remote)
- Log messages are formatted consistently — timestamp, level, logger name, message
- Multiple loggers can exist with independent configurations (per-class or per-module logging)
- Logger hierarchy: a child logger inherits its parent's appenders if not configured"
Interviewer: "What about async logging, log rotation, and structured JSON output?"
Candidate: "Log rotation and async delivery are infrastructure concerns — I'll design appenders with a clean interface so async wrappers can be added, but async isn't in the core model. Structured JSON output is a formatter variant — I'll design
Formatteras an abstraction soJsonFormatteris just another implementation. Log rotation would be a concern forFileAppender— I'd note it as an extension point but not implement it in the core design."WHY: Keeping infrastructure concerns…
In the full tutorial
- Phase 2: Object Modeling
- Phase 3: Class Design & Relationships
- Phase 4: Design Patterns Application
- Phase 5: Key Implementation
- Phase 6: Extensibility & Trade-offs