Quick revision
The short answer
We get to one format and one place for levels by choosing a single backend, Logback here, and routing everything into it: SLF4J code goes there directly, JUL goes through the jul-to-slf4j bridge with JUL's default handlers removed, and LevelChangePropagator keeps JUL's levels in step so disabled calls stay cheap. The application server needs special care because it may install its own JUL LogManager at JVM start, so we use the hooks it offers. We document one level mapping, retire direct JUL use in our own code, and keep the bridge only for third-party and JDK code.
What to remember
In this answer, we built a single logging path: one backend, SLF4J code going there directly, JUL and System.Logger bridged in with JUL's default handlers removed, and LevelChangePropagator so levels are set only in Logback and disabled JUL calls stay cheap. We treated the application server separately because it may own JUL from JVM start, used its supported hooks, documented the level mapping of the bridge we use, and planned to retire direct JUL use in our own code so that the bridge only serves third-party code.
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.
We get to one format and one place for levels by choosing a single backend, Logback here, and routing everything into it: SLF4J code goes there directly, JUL goes through the jul-to-slf4j bridge with JUL's default handlers removed, and LevelChangePropagator keeps JUL's levels in step so disabled calls stay cheap. The application server needs special care because it may install its own JUL LogManager at JVM start, so we use the hooks it offers. We document one level mapping, retire direct JUL use in our own code, and keep the bridge only for third-party and JDK code.
Why this question is asked
Operations teams care less about which library writes a line than about being able to search, alert and change levels in one way across the product. A product that grew over many years often ends up with two logging systems that each have their own files, formats and switches. Interviewers ask this scenario to see whether we can make that whole without breaking the application server or hurting performance. In this answer, we will recap the target picture, route JUL into SLF4J, handle the application server, settle the level mapping, deal with the cost of bridging, and plan how to keep it that way.
1A Quick Recap of the Target Picture
The goal is a single path for every log line. Our newer modules already call SLF4J, the logging API, and Logback, the backend. The older parts, the application server and JDK tools call java.util.logging (JUL), the JDK's own framework, or System.Logger, which uses JUL underneath by default. Instead of trying to make two systems produce the same format, we pick one backend and send everything into it. Then there is one configuration file, one format (for example JSON for the log platform), one set of appenders and one place to change levels.
- Callersour SLF4J code, legacy JUL code, the application server, JDK tools
- APIsSLF4J,
java.util.logging,System.Logger - Bridgesjul-to-slf4j handler, or slf4j-jdk-platform-logging for
System.Logger - BackendLogback with one
logback-spring.xml - Outputone JSON format to stdout or files, shipped to the log platform
5 layers, from the top down. Step through them one at a time.
Every API ends in the same backend, so format and levels are defined once.
2Routing JUL Into SLF4J
For JUL, we add the jul-to-slf4j bridge and install it as early as possible at startup. Installing it means two calls: removing the handlers JUL's root logger already has, so the default ConsoleHandler stops printing its own two-line format to stderr, and adding SLF4JBridgeHandler, which hands every JUL record to SLF4J. In a Spring Boot module this happens automatically; in a plain application we do it in main or in a startup listener.
If the product used Log4j2 as its backend instead, the cleaner route is log4j-jul's LogManager, enabled with -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager. JUL loggers then become Log4j loggers directly, with no handler step and no second set of levels.
3Handling the Application Server
The application server is the hard part, because it often owns JUL before our code runs. Tomcat, for example, starts with its own LogManager implementation (JULI) set through the java.util.logging.manager property in its startup scripts, and reads its own conf/logging.properties. Other servers ship their own log manager too. If we install the bridge from inside a deployed application, we may only see that application's records, or we may change global JUL state that other applications on the same server share.
So we check what the server supports and use that. Many servers let us replace or configure the log manager through a JVM property set at start, or let us declare a handler in their own logging configuration, which is where the SLF4JBridgeHandler should go so that it captures the server's own messages from the first second. Some products ship a supported integration for SLF4J or Log4j2 instead. Whatever the route, we test it by starting the server, checking that its startup lines appear in our format, and checking that nothing is still being written to the old files.
Notice that this is the step to agree with the vendor or the platform team. A setting that the server does not support may work until the next upgrade and then silently send logs back to the old place.
4Agreeing One Level Mapping
JUL has seven levels and SLF4J five, so we must write down how they line up. The bridge already decides this: SLF4JBridgeHandler sends FINEST to TRACE, FINER and FINE to DEBUG, CONFIG to INFO, WARNING to WARN and SEVERE to ERROR. Log4j2's JUL support maps a little differently. Our documentation should state the mapping of the bridge we actually use, because operators will read library manuals that say "enable FINER" and need to know that means DEBUG in our system.
In the other direction, LevelChangePropagator translates our Logback levels into JUL levels (DEBUG becomes FINE, TRACE becomes FINEST). That gives the operations team one rule: levels are only ever set in Logback, through application properties or the logback file, and never in a logging.properties file.
The propagator also matters for speed. Without it, a JUL logger that still has FINE from an old file builds a record for every fine() call, which the bridge then passes to Logback only to be dropped. With it, JUL's own check refuses the call at once.
5Making It Last: Retiring Direct JUL Use
The bridge is a translation layer, and each translated record costs more than a native SLF4J call. It also keeps two concepts alive in the codebase. So the plan is to move our own legacy modules from JUL to SLF4J over time, which is a mechanical change that can be done module by module, often with a simple rewrite of Logger.getLogger and the level method names. A build rule can then forbid new imports of java.util.logging in our code.
After that, the bridge stays only for code we do not own: the application server, the JDK tools and third-party libraries. We record this in the architecture notes, so nobody later removes jul-to-slf4j because "we do not use JUL".
- Choose one backendLogback, with one configuration file
- Bridge JUL and System.Loggerremove JUL root handlers, install the bridge early
- Configure the server's hooka supported log manager or handler setting at JVM start
- Add LevelChangePropagator
resetJULtrue, levels set only in Logback - Document the level mappingFINE to DEBUG and so on, as the bridge does it
- Migrate own JUL codemodule by module, then forbid new JUL imports
6 steps in order. Play them, or step through them one at a time.
6Follow-up questions
Where does System.Logger fit in this plan?
System.Logger is the small logging API the JDK's own modules use since Java 9. By default its backend is JUL, so once JUL is bridged, System.Logger output arrives in Logback as well, but it goes through two layers. To make it direct, we add slf4j-jdk-platform-logging, which registers a LoggerFinder that sends System.Logger calls straight to SLF4J (with Log4j2, log4j-jpl does the same). For our own code, I would still use SLF4J; System.Logger makes sense mainly for small libraries that want no dependencies at all.
What if two applications share one server and want different levels?
JUL configuration is global to the JVM unless the server provides per-application log managers, as Tomcat's JULI does. In that case, each application's Logback configuration controls its own loggers, and the server's own loggers are set in one shared place that the operations team owns.
How do we know nothing still logs the old way?
We search the running hosts for log files and stderr output that do not match the agreed format, and we add a startup check that fails or warns if JUL's root logger still has a handler other than the bridge.
7Conclusion
In this answer, we built a single logging path: one backend, SLF4J code going there directly, JUL and System.Logger bridged in with JUL's default handlers removed, and LevelChangePropagator so levels are set only in Logback and disabled JUL calls stay cheap. We treated the application server separately because it may own JUL from JVM start, used its supported hooks, documented the level mapping of the bridge we use, and planned to retire direct JUL use in our own code so that the bridge only serves third-party code.
Open with
My goal would be one backend and one configuration, and everything else bridged into it. We already have SLF4J and Logback in the newer modules, so Logback becomes the backend.
Then, if they want more
For JUL, I add jul-to-slf4j, remove the JUL root handlers so the old ConsoleHandler format disappears, and install SLF4JBridgeHandler as early as possible. If we were on Log4j2, I would use the log4j-jul LogManager set at JVM start instead. Then I add Logback's LevelChangePropagator with resetJUL, so levels are set only in Logback and copied to JUL.
That matters for performance, because otherwise a JUL logger left at FINE builds records that Logback drops.
The application server needs care, because servers like Tomcat install their own LogManager at JVM start, so I would use the server's supported hook, a JVM property or a handler in its own logging configuration, and test that its startup lines come out in our format.
I would document the level mapping of our bridge, FINE and FINER to DEBUG and FINEST to TRACE for jul-to-slf4j, so operators can translate library docs. Finally I would migrate our own JUL code to SLF4J module by module and add a build rule against new JUL imports, keeping the bridge only for the server, the JDK and third-party libraries. System.Logger I route with slf4j-jdk-platform-logging.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 9
- 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 "A product built on an application server and several JDK-internal tools logs through...": https://scrivio-interview-library.netlify.app/java/java-logging/58874f2bef/