Interface LogBackend
- All Known Implementing Classes:
JulLogBackend,Log4j2LogBackend,LogbackLogBackend
/loggers management endpoint: reads and sets logger levels for one concrete logging
backend at runtime.
juneau-rest-server ships only the java.util.logging implementation, keeping the
core management surface dependency-free. Support for other backends is opt-in: the
juneau-rest-server-management-logging add-on ships LogbackLogBackend / Log4j2LogBackend
(with the backends declared provided), and any consumer can implement this interface for a backend
Juneau does not cover.
Explicit selection (no auto-drive)
Consistent with Juneau's explicit-over-magic stance, the backend is explicitly declared by registering a
LoggersSettings bean built with LoggersSettings.Builder.backend(LogBackend). When none is
declared, LoggersManager drives JulLogBackend — the endpoint never silently classpath-scans
for, and then drives, a backend the operator didn't choose.
Level contract
Levels are exchanged as backend-native level-name strings (e.g. JUL "FINE"/"INFO", Logback /
Log4j2 "DEBUG"/"INFO"). Reads report the logger's configured level — the level set
on the logger itself, or the empty string when it inherits from an ancestor. Sets are
process-lifetime-only (they do not rewrite the backend's configuration file). The root logger is
addressed under the key "ROOT".
See Also:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionReturns the configured level of a single logger.Returns a snapshot of all known loggers and their configured levels.voidSets (or clears) the level of a single logger at runtime (process-lifetime-only).
-
Method Details
-
getLevels
Returns a snapshot of all known loggers and their configured levels.- Returns:
- A sorted map of logger name → configured level name (empty string = inherited from an
ancestor). The root logger is keyed
"ROOT". Nevernull .
-
getLevel
Returns the configured level of a single logger.- Parameters:
name- The logger name ("ROOT"or empty for the root logger).- Returns:
- The configured level name, the empty string if the level is inherited, or
null if no such logger is currently registered.
-
setLevel
Sets (or clears) the level of a single logger at runtime (process-lifetime-only).- Parameters:
name- The logger name ("ROOT"or empty for the root logger).level- The backend-native level name, ornull /blank to clear the logger's own level so it inherits from its ancestor.- Throws:
IllegalArgumentException- Iflevelis non-blank but not a valid level name for the backend.
-