Quick revision
The short answer
We define a log group with logging.group.billing=com.acme.billing,org.hibernate.SQL and set its level once with logging.level.billing=DEBUG. At runtime, if the loggers endpoint is exposed, we POST {"configuredLevel": "DEBUG"} to /actuator/loggers/billing and both loggers change together, without a restart. Spring Boot also ships two predefined groups, web and sql, that work the same way.
What to remember
In this answer, we defined a log group, logging.group.billing=com.acme.billing,org.hibernate.SQL, so one name controls our package and Hibernate's SQL logger, and we set it with logging.level.billing=DEBUG. With the loggers endpoint exposed and secured, a POST of {"configuredLevel": "DEBUG"} to /actuator/loggers/billing changes both at runtime and a POST with null resets them. We also saw the predefined web and sql groups, and the rules that keep runtime changes safe: protected endpoint, never root, and always reset.
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 define a log group with logging.group.billing=com.acme.billing,org.hibernate.SQL and set its level once with logging.level.billing=DEBUG. At runtime, if the loggers endpoint is exposed, we POST {"configuredLevel": "DEBUG"} to /actuator/loggers/billing and both loggers change together, without a restart. Spring Boot also ships two predefined groups, web and sql, that work the same way.
Why this question is asked
When a bug appears in one feature, we usually need detailed logs from several places at once: our own package and the SQL the ORM sends to the database. Setting each logger by hand is slow and easy to get wrong, especially at 2 a.m. in production. Interviewers ask this practical question to see whether we know Boot's log groups and the loggers endpoint, and whether we use them safely. In this answer, we will recap loggers and levels, define the group, change it at runtime and back, look at the predefined groups, and add the safety rules that belong with runtime changes.
1A Quick Recap of Loggers and Levels
Every Logger in a Java application has a name, usually the fully qualified class name, such as com.acme.billing.InvoiceService. Names form a hierarchy by their dots: com.acme.billing is the parent of com.acme.billing.InvoiceService. When we set a level on a parent, every child without its own level inherits it. The root logger sits at the top.
The level decides which messages are written. The usual levels from most to least detailed are TRACE, DEBUG, INFO, WARN and ERROR. A logger at INFO writes INFO, WARN and ERROR, and drops DEBUG and TRACE. Spring Boot lets us set levels in configuration with logging.level.<name>=<level>.
Hibernate is a useful example here. It logs every SQL statement it sends through a logger named org.hibernate.SQL, at DEBUG level. That logger is not under com.acme, so setting our package to DEBUG does not show the SQL. We need both.
2Defining the Group
A log group is a name that Boot maps to several loggers. Setting the group's level sets the level of each member.
Notice that the group name, billing, is not a logger name. It only exists in Boot's configuration, and it is easier to remember and type than two package names. Normally we would not keep the group at DEBUG in production; we would leave logging.level.billing at INFO or not set it, and raise it only while investigating. The SQL lines show the statements with ? placeholders. To see the bound values in Hibernate 6 and 7, we would also add org.hibernate.orm.jdbc.bind at TRACE to the group, keeping in mind that those values may contain personal data.
3Changing the Group at Runtime
The loggers endpoint in Actuator reads and changes logger levels in the running application. It must be exposed over HTTP first, and since it can change behaviour, it must be protected with an operator role.
7 messages in order. Play them, or step through them one at a time.
Because billing is a group, Boot applies the new level to each member, and the effect is immediate: the next DEBUG call in InvoiceService and the next SQL statement are logged. No restart is needed, because Boot calls the logging backend's API to change the level in memory.
There is a catch worth knowing. The change lives only in that one JVM. With six pods behind a load balancer, our POST reaches one pod, so only that pod logs at DEBUG. We either call each pod through its own address or, better, use a platform tool that applies the change to all pods of a service. A restart also brings the level back to the configured value, which is usually what we want.
4The Predefined web and sql Groups
Spring Boot defines two groups for common needs. The web group covers Spring's HTTP codecs, the web framework and related request handling loggers, so logging.level.web=DEBUG shows how requests are mapped and how bodies are read and written. The sql group covers Spring's JDBC template, Hibernate's SQL logger and jOOQ's logger, so logging.level.sql=DEBUG shows the SQL from whichever of these the application uses. The exact members can change between versions, and the loggers endpoint lists them under groups.
Our own billing group appears beside them, which is a quick way to confirm the configuration was picked up.
5Safety Rules for Runtime Changes
Runtime level changes are powerful, so a few rules keep them safe. Only operators should be able to POST to the loggers endpoint, and the endpoint should sit on an internal management port. We change a group or a specific logger, never the root logger, because root at DEBUG turns on every library's debug output and can multiply log volume by a hundred. And we always reset the level when we are done; a calendar reminder or an automatic reset after, say, 30 minutes avoids the forgotten DEBUG that fills disks and slows the service.
6Follow-up questions
What is the difference between configuredLevel and effectiveLevel?
configuredLevel is the level set directly on that logger or group, or null if none is set. effectiveLevel is the level actually in force after inheritance from parents. A logger with no configured level shows null as configured and, for example, INFO as effective.
Can a logger belong to two groups?
Yes. The group is only a shortcut for setting levels, so a logger such as org.hibernate.SQL can be a member of both sql and billing. Whichever group was set most recently decides its level, so overlapping groups can surprise us.
Does this work with Log4j2 too?
Yes. Log groups and the loggers endpoint are part of Spring Boot's LoggingSystem abstraction, so they work with Logback, Log4j2 and java.util.logging alike.
7Conclusion
In this answer, we defined a log group, logging.group.billing=com.acme.billing,org.hibernate.SQL, so one name controls our package and Hibernate's SQL logger, and we set it with logging.level.billing=DEBUG. With the loggers endpoint exposed and secured, a POST of {"configuredLevel": "DEBUG"} to /actuator/loggers/billing changes both at runtime and a POST with null resets them. We also saw the predefined web and sql groups, and the rules that keep runtime changes safe: protected endpoint, never root, and always reset.
Open with
I would define a log group in application properties: logging.group.billing=com.acme.billing,org.hibernate.SQL. The group name billing then stands for both loggers, our own package and Hibernate's SQL logger, which logs statements at DEBUG and is not under our package, so it needs to be included explicitly.
Then, if they want more
To turn it on in configuration I set logging.level.billing=DEBUG, and Boot applies that level to each member. In production I would normally leave it at INFO and raise it only when investigating. For runtime changes, I expose the loggers endpoint, protected with an operator role on the management port, and POST a JSON body with configuredLevel DEBUG to /actuator/loggers/billing.
Boot changes both loggers immediately, no restart. When I am done, I POST configuredLevel null to go back to inherited levels. Two caveats: the change only affects the pod that received the request, so with several pods I need to apply it to each or use a tool that does, and I would never change the root logger.
Boot also has predefined groups, web and sql, that work the same way, and GET /actuator/loggers lists the groups and their members.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Hibernate 6
- 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.
- Official documentation
- Spring Boot reference
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 "Set DEBUG for the package com.acme.billing and the Hibernate SQL logger together under...": https://scrivio-interview-library.netlify.app/spring-boot/boot-logging/64456ff1f4/