Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

During an incident, engineers can find the failing trace but cannot find related logs from three services because each logs in a different format and one has no trace id. How do you fix this across services?

Agree on one structured JSON log format with standard fields, timestamp, level, service, trace id, span id and message, and ship it to every service in a shared logging configuration or starter. Then fix the service with no trace ids by checking the usual causes: a missing tracing dependency, an HTTP client that is not instrumented, or context lost on async threads. Finally link traces to logs in the observability tool by trace id, and make a release check that the logs of a test request can be found by its trace id.

Why this question is asked

Incidents are where observability earns its cost, and this scenario is a common way it fails: the trace points to the right place, but the logs that explain the failure cannot be found, because each service formats them differently and one does not log the trace id at all. Engineers then grep by timestamp across three tools while customers wait. Interviewers ask this to see how we turn a painful incident into lasting fixes across teams, not just a quick patch. In this answer, we will look at why the logs are hard to find, agree a common format, deliver it through a shared starter, diagnose the service without trace ids, link traces to logs, and keep it working with a release check.

1Why the Logs Cannot Be Found

A log platform can only join logs to a trace if every log event has the trace id in a field it knows. Here we have three different situations. One service writes plain text, so the trace id, if present, is buried inside a string the platform does not parse. Another writes JSON but calls the field trace_id while the tool expects traceId. The third writes no trace id at all.

Each one breaks the link in a different way, but the result is the same: searching by the trace id finds nothing. So the fix has two parts, a common format so the id is always in the same field, and repairs so every service actually has the id.

2Agreeing on a Common Format

We agree a short schema that every service follows: timestamp in ISO 8601 UTC, level, service name, environment, trace id, span id, logger, thread and message, plus the exception with its stack trace as a field. Choosing an existing schema such as Elastic Common Schema saves debate and matches what tools expect. The important decision is the exact field names, and that they never change between services.

Before and after for the three services
ServiceBeforeAfter
ordersPlain text, traceId inside the lineJSON, trace id field, ECS names
pricingJSON with trace_id, local timeSame schema, UTC timestamps
inventoryJSON, no trace id at allTracing fixed, trace id in every line
All three must end up identical for a trace id search to work.

3Delivering It in a Shared Logging Starter

Writing the format into a wiki page is not enough; teams will copy it differently. We put it in the platform's shared Spring Boot starter, so a dependency upgrade gives every service the same output. With Boot 3.4 or later, the starter sets structured logging properties and adds common fields. For older services, it ships a logback configuration with the logstash encoder.

Properties
# application.properties inside the shared starter (Boot 3.4 and later)
logging.structured.format.console=ecs
logging.structured.ecs.service.name=${spring.application.name}
logging.structured.ecs.service.environment=${app.environment:unknown}
# Every event from every service now looks the same, shortened:
# {"@timestamp":"2026-11-06T09:02:11.204Z","log.level":"ERROR","service.name":"inventory",
# "traceId":"9a1c...","spanId":"5e2b...","message":"stock reservation failed", ...}

Notice that the property names for service fields come from the structured logging support and may differ slightly by version, so check them against the Boot version the starter targets. Non-Java services get the same schema through their logging library or the OpenTelemetry collector, which can also rename fields as a temporary bridge while teams migrate.

4Fixing the Service Without Trace Ids

For the inventory service we work down the likely causes, cheapest first. First, is tracing present at all? Without micrometer-tracing and a bridge on the classpath, nothing puts traceId into the MDC. Second, does the trace reach it? If the calling service creates its HTTP client with new RestTemplate() instead of Boot's builder, no traceparent header arrives, so inventory starts its own trace and its ids do not match the one engineers are looking at. Third, is the context lost inside the service? If the failing code runs on an @Async executor or a custom thread pool, the MDC on that thread is empty.

Step throughWhy a service logs no trace id
  1. Tracing dependency present?
    YesCheck incoming headerNoAdd micrometer-tracing and bridge
  2. traceparent arrives from caller?
    YesCheck threadsNoCaller must use Boot's client builders
  3. Log written on the request thread?
    YesCheck the log formatNoDecorate the executor
  4. Trace id in every lineMatches the trace engineers see

4 steps in order. Play them, or step through them one at a time.

Work from the cheapest check to the most specific.

Each cause has a simple fix: add the dependency through the starter, build clients from RestClient.Builder or WebClient.Builder, and decorate executors with ContextPropagatingTaskDecorator. We confirm by sending one request and checking that the trace id on the inventory log lines equals the one in the trace.

5Linking Traces to Logs and Checking at Release

With consistent fields, we configure the observability tool so that each span offers a link to its logs, a query on the trace id and optionally the service, and each error log line offers a link to its trace. This turns the incident workflow from searching to clicking.

To keep it from breaking again, we add a release check. After deployment to a test environment, an automated job sends a request with a known traceparent header through the main flow and then queries the log platform for that trace id. It expects lines from every service on the path. If one is missing, the release is flagged before it reaches production, and the next time a service changes its logging or its HTTP client, we find out the same day.

6Follow-up questions

Should we fix the format or the missing trace ids first?

During the incident, whichever helps the engineers now, usually a quick query that searches each format. Afterwards, start with the missing trace ids in inventory, because no format can fix data that is not there, then roll out the common format through the starter.

What if a team cannot upgrade to a Boot version with structured logging?

The shared starter can provide a logback-spring.xml with the logstash-logback-encoder for older versions, producing the same field names. The collector or log shipper can also rename fields during a migration, but that is a bridge, not the target.

How do we stop personal data appearing in the new structured fields?

Structured logs make it easier to search everything, including mistakes. The starter should include masking for known sensitive keys and the shipper or collector should drop or redact them, so the new format improves privacy rather than spreading the problem.

7Conclusion

In this answer, we turned an incident into lasting fixes. We agreed on one structured JSON format with standard fields, including trace id and span id, and delivered it through a shared logging starter so every service writes the same events. We fixed the service without trace ids by checking for the tracing dependency, uninstrumented HTTP clients on the caller side and context lost on async threads. Finally, we linked traces to logs in the observability tool and added a release check that finds a test request's logs by trace id across every service.

What to say in the interviewAbout 90 seconds aloud

Open with

The problem is that a trace id search only works if every service logs the id in the same field. Here one logs plain text, one uses a different field name, and one has no trace id.

Then, if they want more

I'd fix it in three parts. First, agree a common structured JSON format with fixed field names: timestamp in UTC, level, service, environment, trace id, span id, logger and message, ideally an existing schema like ECS so tools understand it.

Second, deliver it through our shared Spring Boot starter rather than a wiki page: with Boot 3.4 and later that's the structured logging properties, and for older services a logback configuration with the logstash encoder, so an upgrade makes everyone consistent. Third, fix the service without trace ids.

I'd check, in order, whether micrometer tracing and a bridge are on the classpath, whether the caller sends traceparent, which fails if the caller built its client with new instead of Boot's builder, and whether the failing code runs on an async executor without context propagation, which needs a ContextPropagatingTaskDecorator.

Then I'd configure the tool to link spans to logs by trace id and back. And to keep it working, a release check in the test environment sends a request with a known traceparent and verifies logs from every service can be found by that id.

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 documentation below. 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 "During an incident, engineers can find the failing trace but cannot find related logs...": https://scrivio-interview-library.netlify.app/spring-boot/observability/751e8f929f/