Quick revision
The short answer
Services write structured JSON to stdout in Kubernetes, or to a rotated local file on virtual machines, and a node-level shipper owns delivery, retries and back-pressure. The format has a fixed field schema: UTC ISO-8601 timestamp, level, logger, thread, message, trace id, span id, service, version, environment, error type and stack trace. Logging is best effort with a defined overload behaviour, never block requests and drop DEBUG first, with dropped counts tracked; audit and security events that must not be lost go through a separate durable channel. A shared starter carries the appender and encoder configuration, so teams may change levels and add logger categories but not formats or destinations, and each service has a retention and cost budget with volume alerts.
What to remember
In this answer, we designed a logging output standard for 300 services. Services write JSON to stdout or to a rotated local file, and a node shipper owns delivery, buffering and retries. A fixed schema with UTC timestamps, trace ids and service identity makes cross-service queries possible. Logging is best effort, never blocks requests, drops low levels first and counts every drop, while audit events travel through a separate durable channel. The shared starter fixes format and destinations and leaves levels and categories to teams, and per-service budgets with volume alerts keep cost under control.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Services write structured JSON to stdout in Kubernetes, or to a rotated local file on virtual machines, and a node-level shipper owns delivery, retries and back-pressure. The format has a fixed field schema: UTC ISO-8601 timestamp, level, logger, thread, message, trace id, span id, service, version, environment, error type and stack trace. Logging is best effort with a defined overload behaviour, never block requests and drop DEBUG first, with dropped counts tracked; audit and security events that must not be lost go through a separate durable channel. A shared starter carries the appender and encoder configuration, so teams may change levels and add logger categories but not formats or destinations, and each service has a retention and cost budget with volume alerts.
Why this question is asked
With 300 services, every small difference in log output multiplies: one team's timestamps in local time, another's trace id under a different name, a third writing a 50 MB stack trace loop. A logging output standard is what turns the central log store from a pile of text into something we can query across services during an incident. Interviewers ask this design question to see whether we can cover the whole path, from the appender to the bill, and draw a clear line between what the platform fixes and what teams may change. In this answer, we will design the output and delivery path, fix the field schema, define behaviour under back-pressure and the delivery guarantees, separate audit events, decide what teams control through the shared starter, and set cost budgets.
1Output and Delivery: Let the Shipper Deliver
The first decision is that applications do not deliver logs over the network. In Kubernetes, each service writes one JSON object per line to stdout with the console appender; the container runtime captures it, and a shipper running on every node, such as Fluent Bit, Vector or the OpenTelemetry Collector, reads, enriches and forwards it. On virtual machines, services write the same JSON to a local rolling file with a size cap, and the same shipper software runs as a local agent reading the file.
The reason is failure isolation. A local write is fast whatever the log store is doing. Retries, buffering to disk, back-pressure and batching all happen in the shipper, which we configure once per cluster or per host, instead of in 300 application configurations. And because both environments produce identical JSON, the central store and every dashboard treat them the same.
- Service codeSLF4J API; levels and categories chosen by the team
- Shared starterLogback JSON encoder, fixed fields, async and drop policy
- Local outputstdout (Kubernetes) or rotated file with size cap (VM)
- Node shipperenriches, buffers to disk, retries, reports drops
- Central log storeretention tiers, per-service budgets, alerts
5 layers, from the top down. Step through them one at a time.
2The Field Schema
Fixing field names is the most valuable part of the standard, because cross-service queries depend on it. Every event carries the same core fields with the same names and types, whatever the service or language. Timestamps are in UTC in ISO-8601 with milliseconds, so events from different regions sort correctly. Trace and span ids link logs to traces. service, version and environment identify where the event came from; in Kubernetes the shipper also adds pod, node and namespace.
Notice the last field. Beyond the core schema, teams may add their own fields, through MDC values or structured arguments, but under a naming rule, such as lower snake case and no clash with core names, and with a cap on the number of distinct keys per service, because an unbounded set of field names can overload the store's index. The stack trace is a single string field, so it can never be split into separate records, and the starter caps its length so a runaway recursion cannot produce megabyte events.
3Back-Pressure and Delivery Guarantees
The standard has to say plainly what happens when output is slower than input, because otherwise each library default decides. Our rule is that operational logging is best effort and never blocks a request. The starter wraps output in an async appender whose queue never blocks; when it starts to fill, DEBUG and TRACE events are dropped first, then INFO, and WARN and ERROR are kept as long as possible. The shipper buffers to disk during back-end outages and drops the oldest data only when its buffer is full.
Best effort does not mean unmeasured. The starter publishes a counter of dropped events per level, the shipper exports its own discarded and failed counts, and both feed alerts. So the guarantee we offer teams is honest: logs arrive almost always, nothing blocks your requests, and if anything is lost you will know how much and when.
- Async queue has room?YesEnqueue, doneNoNext check
- Level is WARN or ERROR?YesKeep while any space remainsNoDrop and count it
- Shipper back end reachable?YesSend batchNoBuffer to disk, retry with back-off
- Disk buffer full?YesDrop oldest, reportNoKeep buffering
4 steps in order. Play them, or step through them one at a time.
4Audit and Security Events Go Elsewhere
Some events must not be lost: who changed a bank account, who accessed a patient record, every admin login. Those do not fit a best-effort pipeline with a drop policy. The standard therefore says that audit and security events are written through a separate channel, for example a dedicated audit client library that writes to a durable store or a Kafka topic with acks set to all and proper retries, inside or right after the business transaction. They have their own schema, access control and retention.
Keeping them separate also protects the general pipeline. We can change its sampling, retention and cost rules freely, knowing that nothing with legal weight depends on it.
5What Teams May Change
The shared Spring Boot starter carries the whole output configuration: the JSON encoder and field schema, the async appender and its drop policy, the console or file appender, and the stack trace limits. Teams adopt a version of the starter and get the standard. What remains in their control is deliberately small: log levels per logger, through properties, including changing them at runtime through the actuator loggers endpoint; their own logger categories; and extra fields within the naming rules.
What they may not change is the format, the core field names, the destinations or the blocking behaviour. A team that adds its own appender in logback-spring.xml fails a build check. The reason for such a firm line is that every exception breaks a cross-service query or a guarantee someone else relies on.
6Retention and Cost Budgets
Finally, logs cost money in proportion to volume, and a single noisy logger can double a bill. Each service has a daily volume budget and a retention tier, for example 7 days hot and 30 days in cheaper storage for most services, with longer tiers on request. The log platform alerts the owning team when a service exceeds its budget, typically within an hour, so a logger left at DEBUG after an incident is found before the invoice. Monthly reports show each team its volume and cost, which is usually enough to make teams fix their own noise.
7Follow-up questions
How do you migrate services that log plain text today?
In stages. First, the shipper gets parsers for the existing plain text patterns, so old services keep working in the central store. Then each service adopts the starter, which switches it to JSON with a version bump, and we compare a day of output in both forms. Dashboards and alerts that parsed the old text are updated to use fields. We track the number of services still on text and turn off the text parsers once it reaches zero.
Why UTC and not the local time of each region?
Because during an incident we sort and correlate events from many services in several regions. Local times with different offsets, or worse, without offsets, make ordering ambiguous, especially around daylight saving changes. The user interface can always display UTC in the reader's local time.
Can a team get a temporary exception to log more?
Yes, through the budget, not through the format. A team debugging a problem can raise levels for a period with the actuator endpoint, and the volume alert tells them when they forget to lower them again.
8Conclusion
In this answer, we designed a logging output standard for 300 services. Services write JSON to stdout or to a rotated local file, and a node shipper owns delivery, buffering and retries. A fixed schema with UTC timestamps, trace ids and service identity makes cross-service queries possible. Logging is best effort, never blocks requests, drops low levels first and counts every drop, while audit events travel through a separate durable channel. The shared starter fixes format and destinations and leaves levels and categories to teams, and per-service budgets with volume alerts keep cost under control.
Open with
I would start with the path: services never ship logs over the network themselves. In Kubernetes they write one JSON object per line to stdout, on VMs the same JSON goes to a rotated local file with a size cap, and a node-level shipper like Fluent Bit, Vector or the OpenTelemetry Collector does enrichment, disk buffering, retries and back-pressure.
Then, if they want more
That keeps log back-end failures out of the application and gives one configuration per cluster.
Then the schema, which is the most valuable part: a UTC ISO-8601 timestamp, level, logger, thread, message, trace id and span id, service, version, environment, error type and the stack trace as one field, with extra team fields allowed under naming rules and a cap on distinct keys. Next, guarantees: operational logs are best effort and never block a request.
The starter uses a non-blocking async appender that drops DEBUG first and keeps WARN and ERROR longest, and both the starter and the shipper count drops and alert on them. Audit and security events that must not be lost go through a separate durable channel with its own schema and retention.
All of this ships as a shared starter, so teams can change levels, including at runtime through actuator, and add logger categories and fields, but not the format, destinations or blocking behaviour, and a build check stops custom appenders. Finally, each service has a volume budget and retention tier, with alerts when a noisy logger exceeds it.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design the logging output standard for a platform of 300 Java services that run in...": https://scrivio-interview-library.netlify.app/java/java-logging/ef295fc124/