Quick revision
The short answer
java.util.logging (JUL) is the logging framework built into the JDK: named Logger objects form a hierarchy, Handlers such as ConsoleHandler and FileHandler write the records, and Formatters such as SimpleFormatter decide what each line looks like. Its seven levels run from SEVERE down to FINEST, and the LogManager configures everything from logging.properties. Spring applications rarely use it directly because SLF4J with Logback or Log4j2 gives cheaper parameterized messages, MDC, better rolling files and far more flexible output.
What to remember
In this answer, we saw that JUL is the JDK's own logging framework: Loggers in a dotted-name hierarchy, Handlers that write, and Formatters that shape the text, all configured by the LogManager from logging.properties. Its levels run from SEVERE to FINEST and do not map one to one onto SLF4J's. Spring applications prefer SLF4J with Logback or Log4j2 for cheap parameterized messages, MDC, flexible appenders and proper rolling, but JUL still appears through the JDK and some libraries, so we bridge it into SLF4J rather than ignore it.
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.
java.util.logging (JUL) is the logging framework built into the JDK: named Logger objects form a hierarchy, Handlers such as ConsoleHandler and FileHandler write the records, and Formatters such as SimpleFormatter decide what each line looks like. Its seven levels run from SEVERE down to FINEST, and the LogManager configures everything from logging.properties. Spring applications rarely use it directly because SLF4J with Logback or Log4j2 gives cheaper parameterized messages, MDC, better rolling files and far more flexible output.
Why this question is asked
Almost every Java developer has seen a strange two-line log entry in red on the console that does not match the rest of the application's logs. That is usually JUL, coming from the JDK itself or from a library that logs through it. Interviewers ask about JUL because we cannot avoid it completely: even when our code uses SLF4J, parts of the JDK, Tomcat, gRPC and some older drivers still log through it, and we need to know how it works to bring those messages under control. In this answer, we will recap the moving parts of JUL, follow one log call through them, look at its levels and at logging.properties, and then see why Spring teams pick SLF4J instead and where JUL still matters.
1A Quick Recap of the JUL Building Blocks
JUL lives in the java.logging module of the JDK, so it needs no dependency at all. It has three main parts. A Logger is the object our code calls; we get one by name, usually the class name, with Logger.getLogger("com.shop.OrderService"). A Handler takes a log record and writes it somewhere: ConsoleHandler writes to System.err, FileHandler writes to files, and there are also StreamHandler, SocketHandler and MemoryHandler. A Formatter turns a record into text; SimpleFormatter gives a human-readable line and XMLFormatter gives XML.
Loggers form a hierarchy based on the dots in their names. The logger com.shop.OrderService has com.shop as its parent, then com, and at the top there is the root logger, whose name is the empty string. This matters because a logger without its own level inherits the level of its nearest configured ancestor, and by default a record is also passed up to the handlers of every ancestor. In a fresh JVM, only the root logger has a handler: one ConsoleHandler.
Notice the output format: a date line with the class and method, then the level and the message on a second line. That is SimpleFormatter's default, and it is the format we see when JUL output shows up unexpectedly in a Spring Boot console.
2Following One Log Call Through JUL
When we call LOG.info(...), the Logger first checks whether the level is enabled for it. If the logger has no level of its own, it uses the effective level inherited from its ancestors. If the check fails, the call returns at once. If it passes, the Logger creates a LogRecord, an object that holds the level, the message, the parameters, the time, the thread and the logger name.
The record then goes to the logger's own handlers, and then, because useParentHandlers is true by default, to the handlers of its parent, and so on up to the root. Each handler has its own level and an optional Filter, so a ConsoleHandler at INFO ignores FINE records even if the logger let them through. Finally the handler asks its Formatter for the text and writes it.
- Logger level allows it?own level, or inherited from the nearest ancestorYesBuild a LogRecordNoReturn at once
- Build a LogRecordlevel, message, parameters, time, thread
- Pass to this logger's handlerseach checks its own level and filter
- Pass to parent handlersrepeated up to the root while
useParentHandlersis true - Formatter writes the text
SimpleFormatteror XMLFormatter
5 steps in order. Play them, or step through them one at a time.
The logger level and the handler level are separate gates.
So there are two gates: the logger level and the handler level. A common surprise is setting a logger to FINE and still seeing nothing, because the root ConsoleHandler is still at INFO. Both must allow the level.
3The Seven Levels, From SEVERE to FINEST
JUL levels are objects of the class Level with an integer value. From highest to lowest they are SEVERE (1000), WARNING (900), INFO (800), CONFIG (700), FINE (500), FINER (400) and FINEST (300). There are also OFF and ALL for turning a logger fully off or fully on. The default configuration enables INFO and above.
These levels do not map one to one onto the levels of SLF4J, which are ERROR, WARN, INFO, DEBUG and TRACE. JUL has three fine-grained levels where SLF4J has two, plus CONFIG, which has no direct partner. Bridges therefore have to choose: the jul-to-slf4j bridge, for example, sends FINEST to TRACE, FINER and FINE to DEBUG, and CONFIG to INFO. When we read a library's documentation that says "turn on FINER", we have to translate that into the level of our own backend.
| JUL level | Value | Usual SLF4J level |
|---|---|---|
| SEVERE | 1000 | ERROR |
| WARNING | 900 | WARN |
| INFO | 800 | INFO |
| CONFIG | 700 | INFO (no direct partner) |
| FINE | 500 | DEBUG |
| FINER | 400 | DEBUG (jul-to-slf4j) or TRACE (other bridges) |
| FINEST | 300 | TRACE |
4How logging.properties Configures Everything
JUL is configured by a single object, the LogManager. When the JVM first uses JUL, the LogManager reads a properties file. By default this is $JAVA_HOME/conf/logging.properties (it was jre/lib/logging.properties before Java 9). We can point it at our own file with the system property java.util.logging.config.file, or supply a class that configures JUL in code with java.util.logging.config.class.
Notice how levels are set by logger name plus .level, and how handlers are configured by their class name. The SimpleFormatter.format property uses String.format placeholders, where %1$ is the time, %3$ the logger name, %4$ the level, %5$ the message and %6$ the exception. The FileHandler only rotates by size and count; there is no daily rolling and no compression.
5Why Spring Applications Do Not Use JUL Directly
Spring Boot uses SLF4J as the API and Logback as the default backend, or Log4j2 if we choose it. The reasons are practical. JUL's convenience methods such as fine(String) take a finished string, so code tends to build messages with concatenation even when the level is off. JUL does have a parameterized form with {0} placeholders, formatted with MessageFormat, and Supplier variants since Java 8, but they are clumsy and rarely used. SLF4J's log.debug("Order {}", id) is cheap when disabled and is the habit everyone has.
JUL also lacks things we rely on in services: an MDC (mapped diagnostic context) to attach a request id or user id to every line, appenders for JSON, syslog or asynchronous writing, time-based rolling with compression, and configuration that can be changed per environment as easily as logback-spring.xml or application properties. Its configuration is global to the JVM, which is awkward in application servers with many applications.
But JUL still matters. The JDK logs through it, or through System.Logger, which uses JUL by default. Libraries that want zero dependencies log through it too. So in a Spring Boot application we route JUL into SLF4J with the jul-to-slf4j bridge, which spring-boot-starter-logging includes and Boot installs for us.
6Follow-up questions
What is System.Logger, added in Java 9, and how does it relate to JUL?
System.Logger is a small logging API in java.base, added by JEP 264 so that the JDK's own modules do not have to depend on java.logging. We get one with System.getLogger(name), and it has its own levels: TRACE, DEBUG, INFO, WARNING and ERROR, plus ALL and OFF. The actual work is done by a backend found through the System.LoggerFinder service. If no backend is installed and the java.logging module is present, the default backend is JUL, so System.Logger output appears exactly like JUL output. We can plug in SLF4J with slf4j-jdk-platform-logging or Log4j2 with log4j-jpl, which sends these messages straight to our real backend.
If I set com.vendor.level = FINE, why do I still see nothing?
Because there are two gates. The logger now lets FINE records through, but the root ConsoleHandler still has its default level of INFO, so it drops them. We must also lower java.util.logging.ConsoleHandler.level, or attach a handler with a lower level to that logger.
Can JUL avoid building expensive messages?
Yes, with some effort. LOG.fine(() -> "State: " + dump()) takes a Supplier that runs only when FINE is enabled, and LOG.log(Level.FINE, "State {0}", value) delays formatting to the handler. Checking LOG.isLoggable(Level.FINE) first also works. The problem is that the easy fine(String) method encourages concatenation, which runs every time.
7Conclusion
In this answer, we saw that JUL is the JDK's own logging framework: Loggers in a dotted-name hierarchy, Handlers that write, and Formatters that shape the text, all configured by the LogManager from logging.properties. Its levels run from SEVERE to FINEST and do not map one to one onto SLF4J's. Spring applications prefer SLF4J with Logback or Log4j2 for cheap parameterized messages, MDC, flexible appenders and proper rolling, but JUL still appears through the JDK and some libraries, so we bridge it into SLF4J rather than ignore it.
Open with
java.util.logging is the logging framework inside the JDK, in the java.logging module. We get a Logger by name, and loggers form a hierarchy by the dots in the name, up to the root logger.
Then, if they want more
A log call first checks the logger's level, which can be inherited, then builds a LogRecord and passes it to the logger's handlers and up to the parents' handlers. ConsoleHandler writes to stderr, FileHandler writes size-rotated files, and a Formatter, usually SimpleFormatter, makes the text.
The levels are SEVERE, WARNING, INFO, CONFIG, FINE, FINER and FINEST, with INFO the default, and they do not map neatly to SLF4J: CONFIG has no partner and the three fine levels squeeze into DEBUG and TRACE. The LogManager reads JAVA_HOME/conf/logging.properties, or the file named by java.util.logging.config.file, where we set levels per logger name and configure handlers.
Spring apps do not use it directly because its convenience methods take finished strings, it has no MDC, its appenders and rolling are basic, and its configuration is global. SLF4J with Logback gives all of that.
We still care about JUL because the JDK, Tomcat, gRPC and some drivers log through it, so in Boot we install the jul-to-slf4j bridge and everything ends up in one place.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 8, 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 "Explain java.util.logging: Logger, Handler, Formatter, its levels (SEVERE to FINEST)...": https://scrivio-interview-library.netlify.app/java/java-logging/8c12adff9c/