Learning on Web Dev Open is free for all.

Interview Prep · Low Level DesignDesign a logging library
← Low Level Design

Design a logging library

Medium35 minFree, no account

Everyone gets the levels right. The marks are in what happens when the sink is slow.


The question

Design a logging library: levels, several destinations, structured fields, and configuration per module.

Logging must not block the caller, and must not lose everything when the destination is slow.

Functional
  • Levels: trace, debug, info, warn, error, fatal.
  • Multiple sinks, console, file, network, each with its own minimum level and format.
  • Structured key-value context, inherited by child loggers.
  • Per-module level configuration, changeable at runtime.
Non-functional
  • A disabled log call costs essentially nothing.
  • A slow sink must not block application threads.
  • Under overload, drop deliberately rather than growing without bound.
35:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Made a disabled call genuinely cheap and explained how25
  • Moved IO off the calling path20
  • Bounded buffer with a deliberate drop policy by level25
  • Sinks never throw into the caller; drops are counted20
  • Per-module configuration with inheritance10

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only