Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Log volume costs your company more than its databases, logs contain personal data, and retention differs by team. How would you set a long-term logging strategy covering cost, privacy and usefulness?

I would classify logs by purpose, debugging and operations, audit, and security, and give each class its own retention, access rules and storage tier. Personal data is kept out of debug logs by masking in the shared logging configuration and by automated checks, while audit and security logs stay complete, protected and separate. Volume comes down through sensible levels, sampling of high-volume logs and using metrics or traces where they answer the question better, and each team sees its logging cost against a budget.

Why this question is asked

When logging costs more than the databases, it usually means logs have become the default answer to every question: debugging, metrics, auditing and analytics all go into the same stream with the same retention. At the same time, personal data slips into debug lines, which turns the log platform into a privacy risk, and each team keeps logs for as long as it likes. A senior leader is expected to replace that with a strategy that is cheaper, safer and still useful. Interviewers ask this to see how we balance three goals that pull against each other. In this answer, we will classify logs by purpose, set retention and access per class, deal with personal data, reduce volume, make cost visible, and protect the logs that must never be reduced.

1Why One Policy for All Logs Fails

Different logs answer different questions. A debug or operations log helps an engineer understand what a service did in the last few days; after two weeks almost nobody reads it. An audit log records who did what to which data, and regulators or customers may ask for it years later. A security log, such as authentication events or admin actions, feeds threat detection and investigations and needs to be complete and tamper-resistant.

Treating all of them the same means we either keep debug noise for years, which is what drives the bill, or we risk deleting audit evidence too early. So the first decision is to separate them.

2Classify Logs by Purpose

We define three classes and give each a home. Every log statement or log source belongs to exactly one class, chosen by the team and checked in review. In code, the simplest way is separate loggers, for example an AUDIT logger whose events go to a different pipeline.

Java
private static final Logger log = LoggerFactory.getLogger(PaymentService.class); // operations
private static final Logger audit = LoggerFactory.getLogger("AUDIT"); // audit class
log.debug("retrying authorisation, attempt {}", attempt); // short retention, may be sampled
audit.info("refund approved by={} payment={} amount={}", // complete, protected, long retention
approverId, paymentId, amount);
Log classes and their rules
ClassRetentionAccessVolume rules
Debug and operations7 to 14 days hot, then deleteOwning teams, on-callLevels, sampling, drop noise
AuditPer regulation, often yearsRestricted, read loggedNever sampled or dropped
Security1 year or moreSecurity team, SIEMNever sampled; tamper-resistant
Example values; legal and security teams set the audit and security numbers.

3Keeping Personal Data Out of Debug Logs

Personal data in logs is risky because debug logs are widely readable, copied to many systems and hard to delete on request. The rule is that operations logs carry opaque internal ids, never names, emails, addresses, card numbers or full request bodies. Rules alone fail, so we add three layers of protection.

First, masking in the shared logging configuration: the platform starter adds a converter or a structured logging customiser that masks known sensitive field names and patterns, such as anything that looks like an email or a card number, before the event leaves the JVM. Second, the shipper or collector applies the same rules again as a safety net for non-Java services. Third, automated checks: a scheduled job samples recent logs and searches for patterns, and the finding opens a ticket for the owning team. Logging entire request or response bodies is banned in production configurations, since it is the most common source of leaks.

4Reducing Volume Without Losing Usefulness

Most volume comes from a few sources. We sort log sources by volume and by how often they are queried; the big, never-searched ones are the targets. The usual fixes are running production at INFO with targeted DEBUG enabled temporarily through Actuator's loggers endpoint, dropping health check and readiness probe access logs, sampling repetitive high-volume lines such as per-message processing logs at 1 to 10 percent, and deduplicating repeated errors.

The bigger change is moving questions to the right signal. A log line per request used to count requests is a metric in disguise; a counter is thousands of times cheaper. A sequence of log lines used to follow a request across services is what traces do better. When we replace those patterns, log volume often drops by a third or more while engineers get better answers.

Java
# Turn on DEBUG for one package during an investigation, then turn it off
curl -X POST localhost:8081/actuator/loggers/com.example.payments \
-H 'Content-Type: application/json' -d '{"configuredLevel":"DEBUG"}'
# -> 204, DEBUG lines from com.example.payments appear immediately

5Making Cost Visible and Setting Budgets

People change what they can see. We tag every log event with the owning service and team, which the shared configuration already provides, and publish a monthly report of ingested gigabytes and cost per team, with the top sources. Each team gets a budget agreed with its leadership, based on its current spend minus a reduction target, for example 30 percent in the first year.

Budgets are a conversation, not a cap that drops logs during an incident. When a team is over budget, it reviews its top sources with the platform team. When a team needs more for a good reason, such as a new regulated product, the budget is raised explicitly. The result is that logging cost becomes a decision someone owns rather than a side effect.

6Protecting Audit and Security Logs

The cost work must never touch the logs that prove what happened. Audit and security events go through a separate pipeline from debug logs, are never sampled or dropped by level rules, are stored in write-once or append-only storage with restricted access, and every read of them is itself logged. Their retention is set with legal and security teams, not by engineering preference.

Keeping them separate also makes debug logs cheaper: once audit data is not mixed in, we can safely shorten debug retention and sample aggressively without fear of deleting evidence. The strategy is reviewed yearly, because regulations, products and costs change.

7Follow-up questions

How do we handle a deletion request for a person's data in logs?

If operations logs hold only opaque ids and have short retention, the request is satisfied by expiry within days, which is the main reason for the rule. Audit logs that must keep a person's actions for legal reasons are handled under the legal basis agreed with the privacy team, which is another reason to keep them separate.

Is sampling logs safe during incidents?

Sampling repetitive success lines is safe; sampling errors and warnings is not. Most setups keep every WARN and ERROR and sample only high-volume INFO and DEBUG lines from known sources. When an incident starts, teams can raise levels temporarily for the affected services.

Who owns the strategy?

The platform or observability team owns the pipeline, the shared configuration and the reports. Security and legal own the rules for audit and security classes. Product teams own their own logs and budgets. Writing that down avoids each group assuming another one handles privacy.

8Conclusion

In this answer, we built a long-term logging strategy. We classified logs by purpose into debugging and operations, audit, and security, each with its own retention, access and storage. We kept personal data out of debug logs with masking in the shared configuration, a second filter in the pipeline and automated checks. We reduced volume through levels, dropped noise, sampling and moving metric-like and trace-like logs to the right signal, showed cost per team against budgets, and kept audit and security logs complete, protected and separate.

What to say in the interviewAbout 80 seconds aloud

Open with

I'd start by separating logs by purpose, because one policy for everything is what makes them expensive and risky. Debug and operations logs help engineers for a week or two, so they get short retention, team access and aggressive volume rules.

Then, if they want more

Audit logs record who did what, and security logs feed detection, so those are complete, never sampled, protected and kept as long as legal and security say, in a separate pipeline.

For privacy, the rule is that operations logs only carry opaque ids, no names, emails or request bodies, and I wouldn't rely on the rule alone: the shared logging starter masks known sensitive fields and patterns, the collector applies the same rules as a safety net, and a scheduled check scans samples and opens tickets.

For cost, I'd rank log sources by volume and by how often they're queried. Usually production at INFO, dropping health check logs, sampling high-volume success lines and replacing log-based counting with metrics and log-based request following with traces cuts a third or more.

Then I'd make it visible: monthly cost per team with top sources and a budget agreed with each team's leadership. And I'd review the strategy yearly as products and regulations change.

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 "Log volume costs your company more than its databases, logs contain personal data, and...": https://scrivio-interview-library.netlify.app/spring-boot/observability/36a0730fed/