Preparing your design workspace

Loading the problem and your saved attempt…

Design a Configurable Logging Framework

Design a thread-safe, extensible in-process logging framework with levels, formatting, an ordered handler pipeline including truncating and in-memory storing handlers, console and file output, runtime configuration, and optional asynchronous delivery.

Design a logging framework similar to Log4J. Support DEBUG, INFO, WARN, and ERROR levels; named loggers; configurable formatting; console and file appenders; extensible appenders and formatters; thread-safe use; and both synchronous and asynchronous output.

A logger can also be built from an ordered list of handlers: every message it accepts passes through each handler in that order. Include a truncating handler and a storing handler that keeps messages in memory without printing them.

For this exercise, assume an application submits a log event to a named logger, which filters by level, formats the event, and routes it to every configured appender. Configuration may be replaced at runtime, and each log call must observe either the complete old or complete new immutable configuration.

Asynchronous appenders use a bounded buffer and expose an explicit overflow policy.

For this exercise, also assume that a handler may hand a changed copy of the message to the handlers after it; the truncating handler shortens any longer message to a positive maximum length fixed when it is created; the storing handler keeps the messages it receives in arrival order in a bounded in-memory list, discards the oldest and counts the discard when full, and offers a read-only snapshot that is safe to take while other threads log; a handler that throws is reported and skipped while the handlers after it still receive the message; and console and file appenders are simply handlers that write output.

Distributed aggregation, file rotation, retention, and remote search are outside scope.