1. Overview

In this lesson, we’ll focus on a core Spring Boot feature: actuators. We’ll look at what actuators are, how to enable them, and how to work with two of the most common built-in endpoints. We’ll also explore how to customize the paths these endpoints are served on.

The relevant module we need to import when starting this lesson is: actuators-in-boot-start.

If we want to reference the fully implemented lesson, we can import: actuators-in-boot-end.

2. Enabling Actuators

Simply put, actuators are monitoring tools that bring production-ready features into our application with very little effort. They provide various endpoints, mainly exposed via HTTP (but also JMX), that help in monitoring and, to some extent, managing our application. Through actuators, Spring Boot provides built-in functionality such as auditing, health checks, and metrics. We can also create custom actuators using the same infrastructure.

It’s worth noting that actuators are a Spring Boot-specific feature, available out-of-the-box with Boot.

The simplest way to enable actuator support is to add the spring-boot-starter-actuator dependency to our pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

The version is managed by the Boot parent, so we don’t need to specify it here.

Boot provides a number of built-in endpoints, all well documented in the official reference. Out of these, two endpoints are available by default: /health and /info.

3. The /health Endpoint

Let’s start the application and have a look at what’s available. In the log output, we’ll see a line confirming our actuator endpoints are active:

Exposing 2 endpoint(s) beneath base path '/actuator'

This tells us that /health and /info are ready under the /actuator base path.

Let’s hit the health endpoint:

curl localhost:8080/actuator/health
{"status":"UP"}

This bare minimum response confirms the application is up and running. The /health endpoint can be enhanced significantly to expose more detailed information about the application’s health; we’ll explore that in a later lesson.

4. The /info Endpoint

Now let’s hit the info endpoint:

curl localhost:8080/actuator/info
{}

We get an empty JSON object because we haven’t configured any application info yet.

4.1. Enabling Environment Info

To make the /info endpoint read info.* properties from the environment, we first need to enable this behavior explicitly. Let’s add the following to application.properties:

management.info.env.enabled=true

4.2. Adding Application Info Properties

Now let’s add some info about our application:

info.lsapp.name=Learn Spring Application
info.lsapp.description=Learn Spring Application Built With Spring Boot

The property pattern is straightforward: everything under the info. prefix gets picked up by the /info endpoint. Here, we’re nesting our properties under info.lsapp, which means they’ll appear grouped under a lsapp key in the JSON response.

Let’s restart the application and hit the endpoint again:

curl localhost:8080/actuator/info
{
    "lsapp": {
        "name": "Learn Spring Application",
        "description": "Learn Spring Application Built With Spring Boot"
    }
}

The /info endpoint now returns our configured application metadata. Beyond simple text properties, there’s support for exposing richer information as well; the official reference covers the full range of options.

5. Configuring Actuator Paths

By default, all actuator endpoints are available under the /actuator base path. Both the base path and individual endpoint paths can be customized via properties.

5.1. Changing the Base Path

Let’s change the base path from /actuator to /monitoring by adding to application.properties:

management.endpoints.web.base-path=/monitoring

After restarting, the old path /actuator/health now returns a 404, while the new path works as expected:

curl localhost:8080/monitoring/health
{"status":"UP"}

This change applies to all actuator endpoints, not just a single one. Every endpoint is now available under /monitoring.

5.2. Changing an Individual Endpoint Path

We can also remap a specific endpoint’s path. For example, let’s change /info to /information:

management.endpoints.web.path-mapping.info=/information

After restarting, /monitoring/info returns a 404, while the remapped path works:

curl localhost:8080/monitoring/information
{"lsapp":{"name":"Learn Spring Application","description":"Learn Spring Application Built With Spring Boot"}}

Both of these path properties are commented out in the final end project, leaving endpoints at their default paths.

6. The /loggers Endpoint

Spring Boot Actuator also exposes a /loggers endpoint, which allows us to view and configure logging levels at runtime.

Since this endpoint is not enabled by default, we need to explicitly include it. Let’s add the following to application.properties:

management.endpoints.web.exposure.include=loggers,info,health

This property controls which actuator endpoints are exposed over HTTP. Here, we’re enabling /loggers alongside /info and /health.

After restarting, we can see the updated log output now shows three exposed endpoints:

Exposing 3 endpoint(s) beneath base path '/monitoring'

Let’s hit the loggers endpoint. Since we changed the base path to /monitoring earlier, we’ll access it at:

curl localhost:8080/monitoring/loggers

The response includes the full list of loggers and their configuration:

{
    "loggers": {
        "ROOT": {
            "configuredLevel": "INFO",
            "effectiveLevel": "INFO"
        },
        "com.baeldung": {
            "effectiveLevel": "INFO"
        },
        "com.baeldung.ls": {
            "effectiveLevel": "INFO"
        }
    }
}

Each logger entry includes an effectiveLevel (the level in effect, possibly inherited from a parent). When a level is explicitly configured, a configuredLevel also appears. Here, only ROOT has a configured level; the other loggers inherit from it.

We can also change a logger’s level at runtime by sending a POST request. For example, to set the ROOT logger to DEBUG:

curl -X POST localhost:8080/monitoring/loggers/ROOT -H "Content-Type: application/json" -d '{"configuredLevel":"DEBUG"}'

After this request, the application immediately starts logging at DEBUG level. This is particularly useful for troubleshooting issues in a running application without having to restart it.

7. Conclusion

In this lesson, we’ve looked at Spring Boot actuators and how they provide powerful monitoring capabilities with minimal setup. We added the starter dependency and configured three endpoints: /health for basic application status, /info for custom application metadata, and /loggers for viewing and changing log levels at runtime.

We also explored how to customize actuator paths, both the base path for all endpoints and individual endpoint paths, all through simple configuration properties.