About Us Contact Us Write for Us Advertise
Home > Java > Spring Boot Actuator & Logging (Beginner Guide)
Java

Spring Boot Actuator & Logging (Beginner Guide)

Monitor and debug production Spring Boot apps: Actuator health and metrics endpoints, proper logging with @Slf4j and log levels, and configuring output per environment.

Shiv Pandey
Shiv Pandey
Oct 07, 2026 | 126 views
Spring Boot Actuator & Logging (Beginner Guide)

Building an app is one thing; running it reliably in production is another. When your app is live, you need to answer questions like "is it healthy right now?" and "what went wrong at 3am?" The tools for this are Actuator (health & metrics) and logging — the eyes and ears of a production application. This lesson kicks off the "production & deployment" part of the roadmap.

Spring Boot Actuator: your app's dashboard

Actuator adds ready-made monitoring endpoints to your app — no code required. With one dependency, you get URLs that report your app's health, metrics, and configuration. It's how you (and your monitoring tools) check that a live app is behaving. Add the starter:

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

The most useful endpoint: /health

Visit /actuator/health and your app reports whether it (and things like its database connection) is up:

GET /actuator/health
{ "status": "UP" }   // the app is healthy

This tiny endpoint is hugely important: load balancers, container orchestrators (like Kubernetes), and uptime monitors ping it constantly to know if your app is alive. If it ever returns DOWN, alerts fire. Other handy endpoints include /actuator/metrics (memory, CPU, request counts) and /actuator/info (app details).

Security note: Actuator endpoints can expose sensitive internal details, so by default Spring only exposes /health publicly. If you enable more, protect them behind authentication (see the security lesson). You control what's exposed with management.endpoints.web.exposure.include in your config — expose deliberately, not everything.

Logging: what your app tells you

Logs are the running diary of your application — a record of what it did and when. When something breaks in production, logs are usually how you find out why. The great news: Spring Boot includes a logging system (Logback) out of the box, ready to use.

Writing logs the right way

Don't use System.out.println for real applications — use a proper logger. It gives you severity levels, timestamps, and control over output. With Lombok's @Slf4j, it's one annotation:

@Service
@Slf4j   // Lombok creates a 'log' object for you
public class UserService {

    public User register(User user) {
        log.info("Registering user: {}", user.getEmail());
        try {
            return repo.save(user);
        } catch (Exception e) {
            log.error("Failed to register {}", user.getEmail(), e);
            throw e;
        }
    }
}

Note the {} placeholders — the logger fills them in efficiently, which is cleaner and faster than string concatenation.

The log levels (from quietest to loudest)

Level Use for…
ERROR something failed and needs attention
WARN something odd but not fatal
INFO normal notable events (default level)
DEBUG / TRACE detailed diagnostics (dev only)

You set the level in config, so you can run quietly (INFO) in production and verbosely (DEBUG) when hunting a bug — without changing code:

logging:
  level:
    com.myapp: DEBUG      # verbose logs for your own code
    org.springframework: WARN

Early on, I debugged everything with System.out.println and then had to hunt down and delete all those lines later — a mess. Switching to a proper logger with levels changed how I work: I can leave log.debug statements in permanently and just turn them on when I need them. In production, good logs are often the only window into what happened during an incident — this website's logs are what I reach for first whenever something misbehaves, and Actuator's /health is what tells me at a glance that everything's running. Treat logging and monitoring as features, not afterthoughts, and your future self (debugging at 3am) will thank you.

Key takeaways

  • Actuator adds monitoring endpoints; /actuator/health reports if your app is UP — vital for load balancers and uptime checks.
  • Expose Actuator endpoints deliberately and protect sensitive ones behind authentication.
  • Use a proper logger (@Slf4j), not System.out.println; log with {} placeholders.
  • Log levels (ERROR/WARN/INFO/DEBUG) are configurable per environment — quiet in prod, verbose when debugging.

← Previous: Spring Lesson 12 — Spring Boot with PostgreSQL
Next: Spring Lesson 14 — Caching →
↑ Back to the Spring Boot roadmap

Related Articles

Spring vs Spring Boot: The Difference Explained (Beginner Guide)
Java

Spring vs Spring Boot: The Difference Explained (Beginner Guide)

Spring Boot Project Ideas (Beginner to Advanced)
Java

Spring Boot Project Ideas (Beginner to Advanced)

Deploying a Spring Boot App to Production (Beginner Guide)
Java

Deploying a Spring Boot App to Production (Beginner Guide)

Dockerizing a Spring Boot App (Beginner Guide)
Java

Dockerizing a Spring Boot App (Beginner Guide)