Quick revision
The short answer
I would start by measuring: group ERROR and WARN events by service, logger and message template to find the few sources behind most of the volume. Then fix the common causes, which are log-and-rethrow repeating the same stack trace at every layer, client errors logged as ERROR and expected timeouts at ERROR, by logging each exception once at the boundary that handles it. Alerting moves to metrics and error rates, and a short level guideline, code review and a per-service error-volume dashboard keep it clean.
What to remember
In this answer, we cleaned up error logs by measuring first, grouping ERROR and WARN by template to find the few sources behind most of the volume. We fixed log-and-rethrow by logging each exception once where it is handled, such as a @ControllerAdvice or a consumer error handler, set client errors, declined payments and expected timeouts to their proper levels, moved alerting to metrics and error rates, and kept it clean with a short guideline, code review and a per-service error-volume dashboard.
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 start by measuring: group ERROR and WARN events by service, logger and message template to find the few sources behind most of the volume. Then fix the common causes, which are log-and-rethrow repeating the same stack trace at every layer, client errors logged as ERROR and expected timeouts at ERROR, by logging each exception once at the boundary that handles it. Alerting moves to metrics and error rates, and a short level guideline, code review and a per-service error-volume dashboard keep it clean.
Why this question is asked
When ERROR logs fire 50,000 times a day, the level has stopped meaning anything. The on-call team learns to ignore it, and the day a real problem appears it is one line in thousands. This is one of the most common observability problems in growing companies, and interviewers ask it to see whether we fix it with data and a few structural changes rather than a stern email. In this answer, we will measure where the errors come from, look at the three causes that usually explain most of them, fix exception logging at the boundary, move alerting to metrics, and set up the guideline and dashboard that stop the problem from coming back.
1Measure First: Find the Top Sources
Fifty thousand errors a day across 25 services sounds like a huge problem, but it is almost never fifty thousand different problems. In practice, a small number of message templates produce most of the volume. So the first step is a query in the log store that groups ERROR events over the last week by service, logger and message template, or by exception class when the message varies.
With structured JSON logs this is a simple aggregation. With plain text logs, grouping by logger and exception class still works well.
| Service and logger | Template or exception | Per day | Cause |
|---|---|---|---|
orders: OrderController | MethodArgumentNotValidException | 14,200 | client errors at ERROR |
orders: OrderService and two more | PaymentDeclinedException (x3) | 9,600 | log and rethrow |
catalog: PriceClient | ReadTimeout, retry pending | 8,100 | expected timeout |
gateway: AuthFilter | Expired JWT | 6,300 | client errors at ERROR |
| 15 other templates | various | 11,800 | to review |
2Common Cause 1: Log and Rethrow
The most frequent cause is each layer catching an exception, logging it at ERROR, and rethrowing it. One failure then produces the same stack trace two, three or four times.
The rule that fixes it is to log an exception once, at the place that handles it. A layer that cannot handle the exception should let it propagate, or wrap it with added context, without logging. In a Spring MVC service the handling place for request failures is usually a @ControllerAdvice; in a Kafka consumer it is the error handler that decides between retry and the dead letter topic.
3Fix: Log Once at the Boundary, at the Right Level
Moving logging to the boundary also lets us choose the level in one place, based on what the exception means.
Notice how the same idea covers the other common causes. A validation failure is the client's mistake, so DEBUG. A declined payment is a normal business outcome, so INFO. Only the truly unexpected exception, something the service did not anticipate, is logged at ERROR with its stack trace.
Expected timeouts get the same treatment in the client code: a timeout that will be retried is DEBUG, and only the final failure after all retries is reported, once, by whoever handles it.
4Move Alerting to Metrics
Part of the reason error logs are noisy is that alerts are built on them: 'page if more than 100 ERROR lines in five minutes'. That couples alerting to how chatty the code is. A better model is to alert on metrics that describe user impact, such as the rate of 5xx responses, the percentage of failed payments or consumer lag, which Spring Boot exposes through Micrometer with no extra code for HTTP requests. Logs then provide the context once someone is looking. With alerts on rates, a change in logging style cannot create or hide a page.
5Keep It Clean: Guideline, Review and a Dashboard
A clean-up is wasted if the next quarter's code brings the noise back. I would write a one-page level guideline with real examples from our own services, like the table of meanings above plus 'client errors are never ERROR' and 'log exceptions once, where handled'. Code review should check new ERROR lines against it, and a simple static check can flag catch blocks that both log and rethrow.
Finally, a dashboard of ERROR volume per service, per day, shown in the weekly operations review, makes the trend visible. Setting a target, such as fewer than 500 ERROR lines per service per day without a matching incident, gives teams something concrete to aim for. In our example, fixing the top four templates alone takes the 50,000 down to about 12,000 within a sprint or two.
- Group ERROR and WARN by templateweekly query
- Fix the top sourceslog once, right level, no client errors
- Alert on metrics, not lines
- Guideline in code review
- Volume above target?YesBack to the top sourcesNoKeep monitoring
5 steps in order. Play them, or step through them one at a time.
6Follow-up questions
How do you treat third-party libraries that log ERROR for normal situations?
First confirm that the situation really is normal, for example a connection pool logging ERROR when an idle connection is closed by the server. Then raise that specific logger's level in the shared base configuration, or add a filter that downgrades or drops that one message template, and document why. Report the behaviour upstream, and remove the override when a fixed version arrives. Never silence the whole library, because its real errors still matter.
Is it ever right to log a client error at WARN?
Yes, when it suggests something we should look at, for example a burst of authentication failures that may be an attack, or a client sending a deprecated field we plan to remove. Even then, one WARN per pattern or a metric with an alert is better than a WARN per request.
What about WARN volume?
The same method applies. WARN should mean 'unexpected but handled' or 'degraded', and if it is written thousands of times a day it is usually either a retry logged per attempt or a normal condition labelled as unusual. Grouping by template finds those just as it does for errors.
7Conclusion
In this answer, we cleaned up error logs by measuring first, grouping ERROR and WARN by template to find the few sources behind most of the volume. We fixed log-and-rethrow by logging each exception once where it is handled, such as a @ControllerAdvice or a consumer error handler, set client errors, declined payments and expected timeouts to their proper levels, moved alerting to metrics and error rates, and kept it clean with a short guideline, code review and a per-service error-volume dashboard.
Open with
I'd start with data rather than a guideline. I'd group a week of ERROR and WARN events by service, logger and message template, or exception class, and I'd expect a handful of templates to explain most of the 50,000.
Then, if they want more
Usually they fall into three causes. The first is log-and-rethrow: each layer logs the exception and throws it again, so one failure appears three times. The second is client errors logged as ERROR, like validation failures or expired tokens, where our service actually did the right thing.
The third is expected situations at ERROR, like a timeout that will be retried.
The fix for all of them is to log an exception once, at the boundary that handles it, which in a web service is a ControllerAdvice and in a consumer is the error handler, and to choose the level there: DEBUG for client mistakes, INFO for business outcomes like a declined payment, ERROR only for unexpected failures, with the stack trace.
Then I'd move alerting off log lines and onto metrics: 5xx rate, failed payment percentage, consumer lag. Logs give context once someone is looking.
To keep it clean, I'd write a one-page level guideline with our own examples, check new ERROR lines in code review, and put an error-volume-per-service dashboard into the weekly ops review with a target, so regressions are visible.
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 "The on-call team complains that ERROR logs from your 25 services fire about 50,000 times...": https://scrivio-interview-library.netlify.app/java/java-logging/efa70de19f/