Class LoggersManager
java.lang.Object
org.apache.juneau.rest.server.management.LoggersManager
Shared worker for the
/loggers management endpoint: reads and sets logger levels at runtime by
delegating to the LogBackend resolved from the host context.
Both the mixin and resource flavors delegate here, so the
two forms cannot drift — the same pattern the health package uses with its aggregator.
Backend
The driven backend defaults to java.util.logging. A consumer drives a different backend
(e.g. Logback / Log4j2 via juneau-rest-server-management-logging) by explicitly declaring it on a
LoggersSettings bean via LoggersSettings.Builder.backend(LogBackend) — the endpoint never
auto-detects. The response shape (logger name → configured level, empty string = inherited) is identical
across backends.
See Also:
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLevel(RestContext context, String name) Returns the configured level of a single logger, for the backend resolved from the supplied context.getLevels(RestContext context) Returns a snapshot of all known loggers and their configured levels, for the backend resolved from the supplied context.resolveSettings(RestContext context) Resolves theLoggersSettingsfrom the host context's bean store, falling back to the read-only (JUL-backed) default.voidsetLevel(RestContext context, String name, String level) Sets (or clears) the level of a single logger at runtime (process-lifetime-only), for the backend resolved from the supplied context.
-
Constructor Details
-
LoggersManager
public LoggersManager()
-
-
Method Details
-
getLevels
Returns a snapshot of all known loggers and their configured levels, for the backend resolved from the supplied context.- Parameters:
context- The REST context whose bean store supplies theLoggersSettings/LogBackend. May benull (uses the JUL default).- Returns:
- A sorted map of logger name → configured level name (empty string = inherited). Never
null .
-
getLevel
Returns the configured level of a single logger, for the backend resolved from the supplied context.- Parameters:
context- The REST context whose bean store supplies the backend. May benull .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), for the backend resolved from the supplied context.- Parameters:
context- The REST context whose bean store supplies the backend. May benull .name- The logger name ("ROOT"or empty for the root logger).level- The backend-native level name (e.g."FINE"/"INFO"for JUL,"DEBUG"/"INFO"for Logback/Log4j2), ornull /blank to inherit.- Throws:
IllegalArgumentException- Iflevelis non-blank but not a valid level name for the backend.
-
resolveSettings
Resolves theLoggersSettingsfrom the host context's bean store, falling back to the read-only (JUL-backed) default.- Parameters:
context- The REST context whose bean store is searched. May benull .- Returns:
- The registered settings, or
LoggersSettings.DEFAULTwhen none is registered.
-