14.2.7 The Loggers Endpoint

The loggers endpoint returns information about the available loggers in the application and permits configuring the their log level.

To get a collection of all loggers by name with their configured and effective log levels, send a GET request to /loggers. This will also provide a list of the available log levels.

  1. $ curl http://localhost:8080/loggers
  2. {
  3. "levels": [
  4. "ALL", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF", "NOT_SPECIFIED"
  5. ],
  6. "loggers": {
  7. "ROOT": {
  8. "configuredLevel": "INFO",
  9. "effectiveLevel": "INFO"
  10. },
  11. "io": {
  12. "configuredLevel": "NOT_SPECIFIED",
  13. "effectiveLevel": "INFO"
  14. },
  15. "io.micronaut": {
  16. "configuredLevel": "NOT_SPECIFIED",
  17. "effectiveLevel": "INFO"
  18. },
  19. // etc...
  20. }
  21. }

To get the log levels of a particular logger, include the logger name in your GET request. For example, to access the log levels of the logger ‘io.micronaut.http’:

  1. $ curl http://localhost:8080/loggers/io.micronaut.http
  2. {
  3. "configuredLevel": "NOT_SPECIFIED",
  4. "effectiveLevel": "INFO"
  5. }

If the named logger does not exist, it will be created with an unspecified (i.e. NOT_SPECIFIED) configured log level. (It’s effective log level will usually be that of the root logger.)

To update the log level of a single logger, send a POST request to the named logger URL and include a body providing the log level to configure.

  1. $ curl -i -X POST
  2. -H "Content-Type: application/json" \
  3. -d '{ "configuredLevel": "ERROR" }' \
  4. http://localhost:8080/loggers/ROOT
  5. HTTP/1.1 200 OK
  6. $ curl http://localhost:8080/loggers/ROOT
  7. {
  8. "configuredLevel": "ERROR",
  9. "effectiveLevel": "ERROR"
  10. }