liveBook · Manning

/loggers endpoint

As explained in Spring in Action, Sixth Edition

The /loggers endpoint is a Spring Boot Actuator HTTP endpoint that reports and changes configured logging levels.

The Spring Boot Actuator /loggers endpoint shows logging levels for packages and classes in a running application. It can also override a level while the application is running, making it useful when you need more detail from a particular logger. section 15.2.2

{
  "levels": [ "OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" ],
  "loggers": {
    "ROOT": {
      "configuredLevel": "INFO", "effectiveLevel": "INFO"
    },
...
    "org.springframework.web": {
      "configuredLevel": null, "effectiveLevel": "INFO"
    },
...
    "tacos": {
      "configuredLevel": null, "effectiveLevel": "INFO"
    },
    "tacos.ingredients": {
      "configuredLevel": null, "effectiveLevel": "INFO"
    },
    "tacos.ingredients.IngredientServiceApplication": {
      "configuredLevel": null, "effectiveLevel": "INFO"
    }
  }
}

A response lists available levels and loggers. Each logger has a configuredLevel and an effectiveLevel; a null configuredLevel can still produce an effective level, as the tacos entries show. section 15.2.2

Turn on DEBUG for a package

Send a JSON request to /actuator/loggers/tacos/ingredients with configuredLevel set to DEBUG. A subsequent response for that logger shows both configuredLevel and effectiveLevel as DEBUG. section 15.2.2

For a visual alternative, the Spring Boot Admin Loggers screen uses the endpoint to list package and class levels and override them. It can filter loggers by class name or distinguish explicitly configured levels from levels inherited from the root logger. section 16.2.4

If the HTTP endpoint is unavailable, check Actuator web exposure settings. Actuator endpoints can be selectively exposed with management.endpoints.web.exposure.include and management.endpoints.web.exposure.exclude, and secured with Spring Security. section 15.5

How Spring in Action, Sixth Edition covers it

How deep it goes
Shows response fields and a curl override, but does not explain logging-system internals.
Examples
Uses JSON logger reports and a curl request that sets a package logger to DEBUG.
What it assumes
Assumes a running Spring Boot application with Actuator and illustrates HTTP access through curl and JSON.
What you can do after
Operate/configure it by checking effective levels and changing a selected logger's configured level at runtime.
How it connects
Connects Actuator endpoints, inherited root-logger levels, Spring Boot Admin, and Actuator web exposure.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.