Class LoggersManager

java.lang.Object
org.apache.juneau.rest.server.management.LoggersManager

public class LoggersManager extends Object
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 Details

  • Method Details

    • getLevels

      public Map<String,String> getLevels(RestContext context)
      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 the LoggersSettings / LogBackend. May be null (uses the JUL default).
      Returns:
      A sorted map of logger name → configured level name (empty string = inherited). Never null.
    • getLevel

      public String getLevel(RestContext context, String name)
      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 be null.
      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

      public void setLevel(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.
      Parameters:
      context - The REST context whose bean store supplies the backend. May be null.
      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), or null/blank to inherit.
      Throws:
      IllegalArgumentException - If level is non-blank but not a valid level name for the backend.
    • resolveSettings

      Resolves the LoggersSettings from 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 be null.
      Returns:
      The registered settings, or LoggersSettings.DEFAULT when none is registered.