Quick revision
The short answer
I would ship a shared logging starter that contributes one base configuration and exposes only properties for the things teams are allowed to change, after first collecting and diffing all 120 files automatically to learn what teams really customise. Teams get reviewed escape hatches, such as an extra appender enabled by a property, instead of full overrides, services migrate in waves with tests that start the application and assert the log format, and the base configuration is versioned with the platform BOM so improvements arrive with normal dependency upgrades.
What to remember
In this answer, we consolidated 120 drifting logback-spring.xml files without breaking teams. We measured first by parsing and diffing every file to see what teams really change, then shipped a starter whose base configuration is the default and which exposes properties for allowed changes, with logger levels handled by Spring Boot's normal properties. Rare needs go through a reviewed optional file, services migrate in waves with a format test and before-and-after comparison, the base is versioned with the platform BOM, and build and runtime checks detect remaining overrides.
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 ship a shared logging starter that contributes one base configuration and exposes only properties for the things teams are allowed to change, after first collecting and diffing all 120 files automatically to learn what teams really customise. Teams get reviewed escape hatches, such as an extra appender enabled by a property, instead of full overrides, services migrate in waves with tests that start the application and assert the log format, and the base configuration is versioned with the platform BOM so improvements arrive with normal dependency upgrades.
Why this question is asked
When every service has its own copy of logback-spring.xml, every platform improvement becomes 120 pull requests: a new field for trace ids, a fix for a masking pattern, a change in rotation. The copies drift, and the log platform has to understand dozens of formats. But each copy also contains decisions a team made for a reason, and replacing them carelessly breaks someone's alerts or hides someone's debug output. Interviewers ask this design question to see whether we can consolidate without a big-bang rewrite. In this answer, we will measure what teams actually change, design the shared starter and its base configuration, add escape hatches, migrate in waves with tests, version it with the BOM, and detect the services that still override it.
1Measure What Teams Actually Change
Before designing anything, we should know what is in the 120 files. Reading them by hand would take weeks and miss patterns, so I would write a small script that clones every repository, parses each logback-spring.xml, normalises it, and extracts the parts that matter: the encoder or pattern used, the appenders and their classes, the logger elements with their levels, filters, and any includes or profile blocks. Then we group and count.
In practice, the result usually looks like the table below: most of the variation is in a few places, and only a handful of services have something truly special. That tells us which knobs the starter must expose and which services need individual attention.
| Customisation | Services | Starter answer |
|---|---|---|
| Logger levels for own packages | 104 | logging.level properties |
| Different pattern or JSON encoder | 97 | one JSON encoder in the base |
| Extra loggers for noisy libraries | 61 | defaults in base, override by property |
| Rolling file appender for VMs | 23 | file appender enabled by property |
| Special appender (syslog, Kafka, audit) | 7 | reviewed escape hatch |
| Custom filters or converters | 4 | case by case |
2Design the Shared Starter
The starter is a normal dependency that every service already pulls in through the platform BOM. It contains the base Logback configuration as a classpath resource and makes Spring Boot use it by default. A clean way is an EnvironmentPostProcessor in the starter that sets logging.config to the base file as a low-priority default, so it applies unless a service explicitly sets something else. The base file uses <springProperty> to read the few settings teams may change.
Notice that levels stay with Spring Boot's normal logging.level properties, which Boot applies after the file. So the 104 services that only changed levels can delete their XML entirely and move those lines into properties. Notice also that the file appender is switched on by a property rather than copied into each service, so the 23 VM services keep their files with standard rotation and caps. How exactly the conditional include is written depends on the Logback version, so check your version's support for conditions.
3Escape Hatches With Review
Some services have genuine needs the base cannot predict, such as a syslog appender for a legacy security system or a separate audit stream. If the only way to get that is to copy the whole configuration again, we are back where we started within a year. So the base includes an optional file, logback-extra.xml, which a service can provide to add appenders and loggers, but which cannot redefine the root logger's encoder or remove the standard fields.
That file is the reviewed path: a CODEOWNERS rule makes the platform team a required reviewer on it, so each exception is seen once, and recurring requests become a new property in the starter. A full override, a service setting logging.config to its own file, remains technically possible for emergencies but is reported, as we will see in the FAQ.
- Base configuration in the starterencoder, standard fields, masking, noisy-library defaults
- Starter propertiesfile appender on or off, retention caps, selected options
- Spring Boot logging.level propertieslevels per service and per environment
- Optional logback-extra.xmlextra appenders, reviewed by the platform team
- Full override via logging.configemergency only, reported and tracked
5 layers, from the top down. Step through them one at a time.
4Migrate in Waves With Tests
Migration is a code change in each service, so it needs a safety net. The starter provides a test helper that starts the application context with the production profile, logs a known line and asserts the output: valid JSON, the agreed fields present, service.name correct, and the service's own important loggers at the expected levels.
Each wave of about 15 to 20 services follows the same steps: add the starter version, move levels to properties, delete the old XML, run the format test, then deploy to a staging environment and compare a sample of output before and after, including the alerts and saved searches the team relies on. An automated pull request, generated from the diff analysis, does most of the mechanical work for the simple services, so the teams mainly review and merge. The first wave should be volunteers, so the playbook is proven before we reach the services with special appenders.
5Version It With the Platform BOM
The base configuration is code and should be versioned like code. Because the starter is managed in the platform bill of materials, a BOM upgrade brings the new logging configuration along with the new Spring Boot version and other libraries. When we add a field, fix a masking pattern or change a default level, it reaches every service at its next routine upgrade, with release notes, rather than through 120 hand-made changes. Breaking changes, such as renaming a field, follow a deprecation period in which both names are written.
6Follow-up questions
How would you detect services that still override the base configuration?
Two ways that complement each other. At build time, a repository scan or a check in the shared build plugin reports any logback.xml or logback-spring.xml in src/main/resources and any logging.config property. At runtime, the starter reports which configuration file Logback actually loaded, for example as a tag on a startup metric or an info endpoint value, so a dashboard lists every running service using a non-base configuration. The runtime check is the important one, because it also catches overrides set by environment variables in deployment manifests.
What if a team refuses to migrate?
Understand why first: often their file does something the starter does not support yet, which is useful input. If the need is real, add it as a property or a reviewed extra file. If it is only habit, the migration pull request is ready-made and the tests show nothing changes in behaviour, which usually ends the discussion. As a last resort, the platform's deadline for removing support for the old formats in the log pipeline sets the date.
Why not just put the shared logback-spring.xml on every service's classpath?
Because if a service also has its own file with the same name, classpath order decides which one wins, which is fragile and invisible. Setting logging.config to a uniquely named base file as a default, and giving the extensions their own names, makes the precedence explicit.
7Conclusion
In this answer, we consolidated 120 drifting logback-spring.xml files without breaking teams. We measured first by parsing and diffing every file to see what teams really change, then shipped a starter whose base configuration is the default and which exposes properties for allowed changes, with logger levels handled by Spring Boot's normal properties. Rare needs go through a reviewed optional file, services migrate in waves with a format test and before-and-after comparison, the base is versioned with the platform BOM, and build and runtime checks detect remaining overrides.
Open with
I wouldn't start by writing the perfect base file; I'd start by measuring. A script would parse all 120 logback-spring.xml files and group what they contain: encoders and patterns, appenders, logger levels, filters.
Then, if they want more
Typically most services only change levels and the format, a couple of dozen need a rolling file on VMs, and a handful have something special like a syslog appender. That tells me what the starter must expose.
Then I'd build a shared logging starter, managed in the platform BOM, that contains the base configuration and makes it the default, for example by setting logging.config to the base file at low priority.
The base has the JSON encoder, the standard fields, masking and defaults for noisy libraries, and it reads a few allowed settings through springProperty, like enabling the file appender. Levels stay in Boot's logging.level properties, so most services can just delete their XML.
For special cases there's an optional extra file the base includes, with the platform team as required reviewer, instead of full overrides.
Migration happens in waves with automated pull requests and a format test from the starter that starts the context with the prod profile and asserts the output is JSON with the right fields, plus a before and after comparison of alerts in staging. Because it's versioned with the BOM, future changes arrive with normal upgrades.
And I'd detect remaining overrides at build time and at runtime, by having the starter report which configuration file was actually loaded.
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 "Every one of your 120 services has its own logback-spring.xml, copied and changed over...": https://scrivio-interview-library.netlify.app/java/java-logging/eba1d58f82/