Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Teams use different logging backends, patterns and appenders. What would a logging standard for 100 services contain?

The standard picks one backend and ships the shared configuration through a platform starter or a base logback-spring.xml. Every service writes structured JSON to stdout, and the platform collects it. Every event carries the same mandatory fields: service, version, environment, trace id and span id. The standard also sets rules for log levels, lists what must never be logged, such as secrets and personal data, fixes retention per log type, and adds sampling or rate limits so one noisy service cannot flood the system.

Why this question is asked

With 100 services and no standard, logs become hard to use exactly when they matter most. During an incident, an engineer searching across five services finds five timestamp formats, three field names for the trace id, and one service writing to a file inside the container that nobody collects. Interviewers ask this design question to see whether we can turn that mess into a small set of rules that are easy to follow and hard to break. In this answer, we will look at the problems the standard must solve, then go through its parts: backend and shared configuration, output format and transport, mandatory fields, rules for content and levels, and protection against noise.

1The Problems the Standard Must Solve

It helps to be concrete about what goes wrong today. Some teams use Logback, some Log4j2, so a security patch to the logging library is two projects. Patterns differ, so a log search for errors must handle 'ERROR', 'error' and 'E'. Some services write files that rotate inside the container and vanish when the pod is replaced. The trace id appears as traceId, trace_id or not at all, so following one request across services is manual work. And now and then a service logs a full request body with a credit card number in it.

Each of these problems has a simple rule that fixes it. The difficulty is making 100 teams follow the rules, which is why the standard must be delivered as code rather than as a document.

2One Backend and Shared Configuration

I would choose Logback, because it is Spring Boot's default and needs no extra dependencies, and allow Log4j2 only with a reason. One backend means one library to patch, one set of configuration examples and one set of known pitfalls. Application code keeps logging through SLF4J, so the choice can be changed later without touching code.

The shared configuration lives in the platform starter, the library every service already uses. It contributes default properties and, where needed, a base logback-spring.xml that teams include rather than copy. A copied file drifts the day after it is copied; an included file changes for everyone when the platform team improves it.

Properties
# Defaults contributed by the platform starter (Spring Boot 3.4+)
logging.structured.format.console=ecs
logging.structured.ecs.service.name=${spring.application.name}
logging.structured.ecs.service.version=${platform.build.version:unknown}
logging.structured.ecs.service.environment=${DEPLOY_ENV:local}
logging.level.root=INFO
# no logging.file.name: nothing is written to files inside the container

Notice that structured JSON is now one property in Boot 3.4 and later, so the starter does not need a custom encoder at all. Check your version for the exact ecs property names.

3Structured JSON to stdout, Collected by the Platform

Every service writes one JSON object per line to standard output. The container runtime captures stdout, and a log agent running on each node, such as Fluent Bit or the OpenTelemetry Collector, ships it to the central log platform. Services never write log files and never send logs over the network themselves.

The reasons are practical. A JSON line is parsed the same way for every service, with no regular expressions that break when someone changes a pattern. Stdout survives pod restarts because the node agent reads it as it is written, while files inside a container are lost with the container. And keeping the transport in the platform means we can change the log backend, add filtering or change routing without redeploying 100 services.

Step throughHow a log line travels
  1. ApplicationSLF4J call with key-value fields
  2. Logback with ECS JSONone JSON object per line on stdout
  3. Container runtimecaptures stdout per container
  4. Node log agentadds pod and cluster labels, applies rate limits
  5. Log platformindexes fields, applies retention per log type

5 layers, from the top down. Step through them one at a time.

4Mandatory Fields in Every Event

A short list of fields must be present in every log event, because they are what make cross-service searches possible: timestamp in UTC, level, logger name, message, service name, service version, environment, trace id and span id. Thread name and the pod name, which the node agent can add, are useful extras. Business identifiers such as an order id are added as separate key-value fields, not only inside the message, so they can be searched exactly.

Java
log.atInfo()
.addKeyValue("order.id", order.id())
.addKeyValue("payment.method", order.method())
.log("Order placed");
// {"@timestamp":"2026-11-05T10:14:03.218Z","log.level":"INFO",
// "log.logger":"com.acme.orders.OrderService","message":"Order placed",
// "service.name":"orders","service.version":"3.8.1","service.environment":"production",
// "trace.id":"7c1e9b0f4a...","span.id":"a93d...",
// "order.id":"A-88213","payment.method":"card"}

The trace id and span id come from Micrometer Tracing, which puts them in the MDC, the per-thread map of logging context, for the duration of each request; the structured formatter includes them automatically (check your version for the exact field names). With the same field names everywhere, one search for a trace id returns that request's lines from every service in order.

5Rules for Levels, Content and Retention

Levels need shared meaning or they are useless for alerting. ERROR means a request or job failed and someone may need to act. WARN means something unexpected that the code handled. INFO is for significant business events and lifecycle events, a few per request at most. DEBUG is off in production by default and switched on for a limited time when needed.

Some content must never be logged: passwords, tokens, API keys, full card numbers, and personal data beyond what the privacy rules allow, such as full names with addresses or health data. The standard backs this up with code, not just words: a masking converter for known fields in the shared configuration, a test helper that fails when a log line matches a secret pattern, and log platform rules that redact common patterns as a last line of defence.

Retention depends on the log type. Application logs might be kept for 14 to 30 days, audit logs for a year or more as required, and debug output for a few days. Putting this in the platform per log stream keeps costs predictable.

Log level meanings in the standard
LevelUse it forProduction default
ERRORA request or job failed; may need actionOn, alertable
WARNUnexpected but handledOn
INFOBusiness and lifecycle events, few per requestOn
DEBUGDiagnosis detailOff; time-limited when on
TRACEVery fine detailOff

6Sampling and Rate Limits for Noise

One service in a retry loop can log thousands of identical lines per second and push the whole platform over its ingestion limit. The standard handles this at two levels. In the application, repeated identical messages are limited, for example with Logback's DuplicateMessageFilter or a rate-limited logger for known hot paths, and high-volume success logs such as every health check request are not logged at all. In the platform, the node agent enforces a per-service rate limit and samples DEBUG and INFO when it is exceeded, while always keeping WARN and ERROR. A metric of log volume per service, with an alert, shows which team to talk to.

7Follow-up questions

Why not let each team choose its log format, as long as it is JSON?

Because the value is in the shared field names. If one team writes traceId and another trace.id, every cross-service search needs both. Using one schema, such as ECS, means queries, dashboards and alerts work for every service.

How do you get 100 teams to adopt the standard?

Make it the default in the platform starter so a dependency upgrade brings it, give a migration guide for teams with custom configuration, and show a fleet report of services that are not compliant. Most teams adopt it quickly when it removes work rather than adding it.

Where do audit logs go?

Audit events, such as who changed a setting, go to a separate logger and stream with longer retention and stricter access. They use the same JSON format and mandatory fields, but the platform routes them to storage that meets the audit requirements.

8Conclusion

In this answer, we designed a logging standard for 100 services. It uses one backend with shared configuration from a platform starter, structured JSON to stdout collected by the platform, a short list of mandatory fields including service, version, environment, trace id and span id, clear rules for levels, forbidden content and retention, and sampling and rate limits so one noisy service cannot overwhelm everyone. Delivering it as code is what makes it stick.

What to say in the interviewAbout 80 seconds aloud

Open with

I would make the standard something teams get by upgrading a dependency, not by reading a document. It has five parts. First, one backend, Logback since it is Boot's default, with shared configuration from the platform starter or a base logback-spring.xml that teams include instead of copying, and application code logging through SLF4J.

Then, if they want more

Second, structured JSON, ECS format, which is one property since Boot 3.4, written to stdout only, so the platform's node agent collects it and nothing is lost when a pod is replaced.

Third, mandatory fields in every event: timestamp, level, logger, message, service name, version, environment, trace id and span id, with business identifiers like an order id as separate key-value fields. Same names everywhere means one search for a trace id shows the request across all services.

Fourth, rules: clear meanings for each level, DEBUG off in production, a list of things never logged, like secrets, tokens, card numbers and personal data, backed by masking and tests, and retention per log type, for example 30 days for application logs and longer for audit logs.

Fifth, protection from noise: duplicate message filtering in the app, per-service rate limits and sampling in the agent that always keep WARN and ERROR, and an alert on log volume per service.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3.4
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference
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 "Teams use different logging backends, patterns and appenders. What would a logging...": https://scrivio-interview-library.netlify.app/spring-boot/boot-logging/2225989be8/