Class LogbackLogBackend
java.lang.Object
org.apache.juneau.rest.server.management.logging.LogbackLogBackend
- All Implemented Interfaces:
LogBackend
LogBackend adapter for Logback (the SLF4J native
backend), for use behind the /loggers management endpoint.
Drives the concrete Logback LoggerContext — not SLF4J the facade. Register it explicitly:
Level mapping
Levels are Logback level names ("TRACE", "DEBUG", "INFO", "WARN",
"ERROR", "OFF"). Reads report each 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
(Logger.setLevel(...)); the root logger is addressed as "ROOT".
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor using the SLF4J-bound LogbackLoggerContext.LogbackLogBackend(ch.qos.logback.classic.LoggerContext context) Constructor with an explicitLoggerContext(for tests / multi-context setups). -
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).
-
Constructor Details
-
LogbackLogBackend
public LogbackLogBackend()Constructor using the SLF4J-bound LogbackLoggerContext.- Throws:
IllegalStateException- If the bound SLF4J backend is not Logback.
-
LogbackLogBackend
Constructor with an explicitLoggerContext(for tests / multi-context setups).- Parameters:
context- The Logback logger context. Must not benull .
-
-
Method Details
-
getLevels
Description copied from interface:LogBackendReturns a snapshot of all known loggers and their configured levels.- Specified by:
getLevelsin interfaceLogBackend- Returns:
- A sorted map of logger name → configured level name (empty string = inherited from an
ancestor). The root logger is keyed
"ROOT". Nevernull .
-
getLevel
Description copied from interface:LogBackendReturns the configured level of a single logger.- Specified by:
getLevelin interfaceLogBackend- 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
Description copied from interface:LogBackendSets (or clears) the level of a single logger at runtime (process-lifetime-only).- Specified by:
setLevelin interfaceLogBackend- 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.
-