Scrivio Interview library

Logging

18 questions in 6 subtopics.

Logback and Log4j2

CodingFoundations6 min read
How do you switch a Spring Boot application from Logback to Log4j2, and what is the purpose of logback-spring.xml compared to logback.xml?
DesignAdvanced7 min read
Teams use different logging backends, patterns and appenders. What would a logging standard for 100 services contain?
LeadershipPrincipal7 min read
Your company uses three log platforms after acquisitions. How would you decide on consolidation and what is the exit strategy if you later need to change vendor?

Log levels and groups

CodingFoundations6 min read
Set DEBUG for the package com.acme.billing and the Hibernate SQL logger together under one name, and change it at runtime without a restart.
ScenarioIntermediate7 min read
Someone set the root logger to DEBUG in production through the loggers endpoint during an incident and forgot it. Disk filled and latency rose. What controls would you add?
LeadershipPrincipal7 min read
Logging frameworks in Java have changed several times: log4j, commons-logging, SLF4J, Logback, Log4j2, and the Log4Shell incident showed the risk. What long-term rules would you set for logging dependencies?

Structured logging

ConceptFoundations6 min read
How do you enable structured JSON logging in Spring Boot 3.4 or later, and which formats are built in?
DesignIntermediate7 min read
Why would you move from text logs to structured logs, and what fields would you require in each log event?
DesignAdvanced8 min read
Personal data appears in logs across many services and breaks your privacy policy. What would you put in place?

MDC and correlation ids

CodingFoundations7 min read
Add a correlation id to every log line of a request in a Spring MVC application. Show where you set and clear it.
DebuggingIntermediate7 min read
Log lines from @Async methods and CompletableFuture callbacks miss the trace id, while lines from the request thread have it. Why, and how do you fix it?
ScenarioAdvanced7 min read
Incident investigations take hours because logs from 20 services cannot be correlated. How would you introduce correlation across the fleet?

Log performance

CodingFoundations6 min read
Which of these is better and why: log.debug("Order " + order + " total " + total()); or log.debug("Order {} total {}", order, total());?
ScenarioIntermediate7 min read
A service spends 15 percent of CPU on logging and p99 latency spikes when the log collector is slow. What would you change?
LeadershipPrincipal7 min read
Log volume and cost grow faster than traffic in your organisation. How would you decide what to log, what to trace and what to measure, over the long term?

Log files, appenders and patterns

CodingFoundations7 min read
Configure a Spring Boot service to write logs to /var/log/app/app.log, roll at 50 MB, keep 14 days and at most 2 GB in total, and change the console pattern to include the thread name.
DebuggingIntermediate7 min read
A service writes logs synchronously to a file on a network volume. When the volume slows down, request latency jumps and threads block in the appender. What do you change?
DesignAdvanced6 min read
Define where and how logs are written for services running on Kubernetes, VMs and a few legacy servers.