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 GET endpoints (list all / read one) are read-only, but — unlike the PUT/POST set-level endpoint, which mutates runtime logging and is deny-by-default (returns 403 unless a LoggersSettings bean with writes enabled is registered) — they carry no built-in guard of their own: once a resource composes this mixin, GET /loggers and GET /loggers/{name} are reachable by anyone who can reach the resource, exposing the set of registered logger names and their configured levels (topology information, not credentials or request data). Compose this mixin only into a resource, or a subpath of one, that's already covered by whatever authentication/authorization the app applies to its management endpoints generally; this mixin does not add any of its own for the read side.

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.