Quick revision
The short answer
I would keep the desired levels in a source of truth outside the pods, such as a config service, Spring Cloud Config with a refresh bus, a watched ConfigMap or a feature flag system, with each override carrying an expiry time. A small component in every instance applies overrides through Spring Boot's LoggingSystem.setLogLevel and reverts them when they expire, while one change tool records who changed which logger, when and why, posts it to the incident channel, and enforces an allow list of logger prefixes and caps on level and duration.
What to remember
In this answer, we designed a safe way to raise log levels across every instance during an incident. Overrides live outside the pods in a config service, a watched ConfigMap or a feature flag system, each with an absolute expiry. A small component in every instance applies them through LoggingSystem.setLogLevel, remembers the original level and reverts on a local timer. One change tool enforces allowed logger prefixes and caps on level and duration and records who changed what, when and why in the incident channel, restarted pods converge on the declared state, and per-request MDC debugging is the cheaper first option.
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.
I would keep the desired levels in a source of truth outside the pods, such as a config service, Spring Cloud Config with a refresh bus, a watched ConfigMap or a feature flag system, with each override carrying an expiry time. A small component in every instance applies overrides through Spring Boot's LoggingSystem.setLogLevel and reverts them when they expire, while one change tool records who changed which logger, when and why, posts it to the incident channel, and enforces an allow list of logger prefixes and caps on level and duration.
Why this question is asked
During an incident, engineers need detail fast, and the Actuator endpoint on one pod is not enough when the service runs twenty. But a level raised on every pod and then forgotten is how log bills double and disks fill. Interviewers ask this design question to see whether we can build something small that is both quick to use and safe by default. In this answer, we will choose the source of truth, write the component that applies and reverts overrides inside each instance, add the change tool with its audit trail and limits, see what happens when pods restart, and compare all this with per-request debugging, which is often cheaper.
1Why the Source of Truth Must Live Outside the Pods
If the level change only exists in a pod's memory, it is lost when the pod restarts and never reaches new pods created by the autoscaler. And if we change each pod by hand, there is no single place that knows what is currently overridden, so reverting depends on someone remembering. So the first design decision is to store the overrides outside the pods, as data: which service, which logger, which level, set by whom, until when.
Several existing systems can hold that data. A Spring Cloud Config server with Spring Cloud Bus can push logging.level properties and trigger a refresh on every instance. A Kubernetes ConfigMap can be watched by the application through the Kubernetes API, which is faster than waiting for a mounted file to update. A feature flag system, which most companies already have, pushes changes to every instance within seconds. I would pick whichever the company already runs reliably, because the incident is not the time to debug a new dependency.
2The Component Inside Each Instance
Each service gets a small component, shipped in the shared starter, that reads the current overrides from the source of truth, applies them through Spring Boot's LoggingSystem and reverts each one when its expiry passes. Using LoggingSystem rather than Logback or Log4j2 classes directly keeps it independent of the backend.
Notice two details. The component remembers the level each logger had before the override, so reverting restores exactly that, including 'inherit from parent'. And it re-checks expiry on a timer, not only when the source changes, so the revert happens even if the source of truth is unreachable at that moment. That makes the automatic revert local to each pod and therefore reliable.
3The Change Tool: Audit and Limits
Engineers should not edit the source of truth directly. They use one change tool, a chat command or a small internal web page, which validates the request, writes the override with its expiry, and records the change.
8 messages in order. Play them, or step through them one at a time.
The audit record answers the questions a post-mortem will ask: who changed which logger, at what time, why, and until when. Posting it to the incident channel makes the change visible to everyone working on the incident, which avoids two engineers raising different loggers without knowing about each other.
The limits protect throughput and disk. The tool accepts only logger names under allowed prefixes such as com.shop, never the root logger or whole frameworks like org.springframework. It caps the level at DEBUG (TRACE only with a second approval) and the duration at, for example, 30 minutes by default and 4 hours at most. With 20 pods and DEBUG adding perhaps 5 MB a minute per pod, a 30-minute override costs about 3 GB, which is fine; an unlimited root DEBUG override could cost that every few minutes.
4What Happens When a Pod Restarts
Because the overrides live in the source of truth with absolute expiry times, a pod that restarts at 10:12 reads the current overrides on start-up and applies com.shop.payment at DEBUG until 10:30, like all the others. New pods from the autoscaler do the same. If the source of truth is unavailable at start-up, the pod starts with its configured levels, which is the safe default, and picks up the override once the source is reachable again.
This is the main advantage over calling Actuator on each pod: the system converges on the declared state instead of depending on a sequence of calls.
5A Cheaper Alternative: Per-Request Debugging
Before raising a level for the whole service, it is worth asking whether the problem is limited to some requests: one tenant, one user, one region. In that case an MDC-based filter, a Log4j2 DynamicThresholdFilter or a Logback turbo filter keyed on a tenant id, can give DEBUG output for those requests only, while all other traffic stays at INFO. The same change tool can manage those overrides too, with the same audit and expiry, by writing a tenant key instead of a logger name. It is often the better first choice because it costs a fraction of the volume.
6Follow-up questions
What happens if a pod restarts during the 30 minutes?
It reads the current overrides from the source of truth during start-up and applies any that have not expired, so it rejoins the others at DEBUG until the same absolute expiry time. That is why overrides store an expiry instant rather than a duration counted from when each pod applied them. If the source is unreachable, the pod uses its configured levels and applies the override when the source returns.
Why not just use Spring Cloud Bus and logging.level properties without a custom component?
That works for applying changes to every instance, and Spring Cloud's refresh support rebinds logging.level properties on refresh. What it does not give us is the expiry: someone must remember to change the property back. The small component, or a scheduled job in the change tool that removes expired overrides and triggers another refresh, adds that. The audit and limits still belong in the tool.
How do you stop the tool from becoming a single point of failure during an incident?
Keep the fallback simple: engineers with the right role can still call each pod's Actuator endpoint, and the pods revert on their own because each override has an expiry. The tool should be monitored like any other operational service, and it should be built on a source of truth the company already relies on.
7Conclusion
In this answer, we designed a safe way to raise log levels across every instance during an incident. Overrides live outside the pods in a config service, a watched ConfigMap or a feature flag system, each with an absolute expiry. A small component in every instance applies them through LoggingSystem.setLogLevel, remembers the original level and reverts on a local timer. One change tool enforces allowed logger prefixes and caps on level and duration and records who changed what, when and why in the incident channel, restarted pods converge on the declared state, and per-request MDC debugging is the cheaper first option.
Open with
I'd split it into three parts. First, a source of truth outside the pods for the overrides, each one being service, logger, level, who and an absolute expiry time.
Then, if they want more
That could be Spring Cloud Config with a bus refresh, a ConfigMap the app watches, or our feature flag system, whichever the company already runs reliably.
Second, a small component in the shared starter, running in every instance, that reads those overrides, applies them with LoggingSystem.setLogLevel so it works for Logback or Log4j2, remembers the original configured level, and reverts it when the expiry passes, checked on a local timer so the revert happens even if the config source is down.
Because the expiry is absolute, a pod that restarts at minute twelve picks up the override until the same end time, and new pods converge too. Third, a single change tool, a chat command or a small page, which is the only way to create overrides.
It enforces an allow list of logger prefixes, no root and no whole frameworks, caps the level at DEBUG and the duration at 30 minutes by default, and records who changed which logger, when and why, posting it to the incident channel, including when it expires.
I'd also offer per-tenant or per-request DEBUG through an MDC filter in the same tool, because it's often enough and much cheaper than raising a level for all traffic.
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 a safe way for engineers to raise log levels across all instances of a service...": https://scrivio-interview-library.netlify.app/java/java-logging/6c06298f52/