Class LoggersMixin

java.lang.Object
org.apache.juneau.rest.server.servlet.RestMixin
org.apache.juneau.rest.server.management.LoggersMixin

public class LoggersMixin extends RestMixin
Mixin flavor of the /loggers runtime log-level management endpoint.

Composes the logger read/set endpoints into a host resource via @Rest(mixins=LoggersMixin.class). Delegates to a shared LoggersManager worker so the mixin and resource flavors cannot drift.

The mixin is annotated with @Rest(guards=DenyAllGuard.class), so every logger path returns 403 Forbidden until the importer registers a @Bean RestGuardList factory on the host; that list replaces the annotation-derived deny-all, so pair the mixin with whatever authentication/authorization the app applies to its management endpoints. Changing a level through the PUT/POST set-level endpoint additionally requires a LoggersSettings bean with writes enabled.

Backend:

See Also:

Since:
10.0.0
  • Constructor Details

  • Method Details

    • getLoggers

      [GET /loggers] - All loggers and their configured levels.
      Parameters:
      req - The HTTP request.
      Returns:
      A sorted map of logger name to configured level (empty string = inherited).
    • getLogger

      public String getLogger(RestRequest req, @Path("name") String name)
      [GET /loggers/{name}] - One logger's configured level.
      Parameters:
      req - The HTTP request.
      name - The logger name ("ROOT" for the root logger).
      Returns:
      The configured level name, empty string if inherited.
      Throws:
      NotFound - If no logger with that name is registered.
    • setLogger

      public String setLogger(RestRequest req, @Path("name") String name, @Content String level)
      [PUT /loggers/{name}] - Set a logger's level at runtime.

      Sensitive (mutating) — deny-by-default: responds 403 unless a LoggersSettings bean with writes enabled is registered.

      Parameters:
      req - The HTTP request.
      name - The logger name ("ROOT" for the root logger).
      level - The level name (e.g. FINE, INFO, OFF), or blank to inherit from the ancestor.
      Returns:
      The newly-configured level (empty string if inherited).
      Throws:
      Forbidden - If the set-level endpoint is not enabled.
    • setLoggerPost

      public String setLoggerPost(RestRequest req, @Path("name") String name, @Content String level)
      [POST /loggers/{name}] - Set a logger's level at runtime (POST alias of setLogger(RestRequest,String,String)).
      Parameters:
      req - The HTTP request.
      name - The logger name ("ROOT" for the root logger).
      level - The level name, or blank to inherit.
      Returns:
      The newly-configured level (empty string if inherited).
      Throws:
      Forbidden - If the set-level endpoint is not enabled.