Debug Smarter, Not Slower: Master Runtime Logging in Quarkus
Ditch redeploys. Learn how to adjust log levels on-the-fly with Quarkus Logging Manager and troubleshoot production issues like a pro.
When your application misbehaves, logging is the first line of defense for any Java developer. But what happens when changing logs means rebuilding your application? Meet the Quarkus Logging Manager that can dynamically adjust logging configurations at runtime without restarting your app or redeploying containers.
Let's get into how you can quickly get up and running, tackle a practical scenario, and understand the fundamentals of logging in Quarkus along the way.
The Problem: Sudden Performance Issues
Imagine you're developing a Quarkus-based inventory management application, quick-stock
, deployed in Kubernetes. Everything is smooth sailing until the application suddenly experiences performance degradation. Logs are sparse, offering little clue about what's happening.
Rebuilding and redeploying with increased logging verbosity means losing precious time. Quarkus Logging Manager is your best friend here.
Meet the Quarkus Logging Manager
Quarkus Logging Manager allows you to update your logging configuration at runtime via REST endpoints or the Dev UI. It's part of the broader Quarkiverse ecosystem which delivers community-driven, productivity-focused extensions for Quarkus.
Core Logging Concepts in Quarkus
Before we proceed, let's quickly revisit some essential Quarkus logging concepts:
Log Levels:
TRACE
,DEBUG
,INFO
,WARN
,ERROR
, andFATAL
. Adjusting these dynamically helps identify issues without cluttering your logs permanently.Loggers and Categories: Loggers represent specific classes or packages. Configuring loggers per package or class allows focused debugging.
Handlers: Responsible for writing logs to various outputs (console, file, remote service).
Getting Started with Quarkus Logging Manager
First, include the extension in your Quarkus project:
./mvnw quarkus:add-extension -Dextensions="logging-manager"
Alternatively, edit your pom.xml
directly:
<dependency>
<groupId>io.quarkiverse.loggingmanager</groupId>
<artifactId>quarkus-logging-manager</artifactId>
<version>3.3.4</version>
</dependency>
After rebuilding your app once (mvn package
), you now have runtime logging control.
Practical Scenario: Diagnosing Performance Problems
Suppose quick-stock
is currently logging only INFO
and higher. To investigate performance issues, you need detailed logs from the problematic service com.acme.inventory.StockService
.
Adjusting Logging via REST Endpoint
With Logging Manager, you can change log levels on-the-fly:
Run your app (locally or Kubernetes):
./mvnw quarkus:dev
Change log level dynamically via HTTP POST request (using curl):
curl -X 'POST' \
'http://localhost:8080/q/logging-manager' \
-H 'accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'loggerName=com.acme.inventory.StockService&loggerLevel=DEBUG'
Response:
{"name":"com.acme.inventory.StockService","configuredLevel":"DEBUG","effectiveLevel":"DEBUG"}
Instantly, your logs from StockService
become verbose enough to diagnose the slowdowns.
Checking Logger Configuration
To see current configurations:
curl -X 'GET' \
'http://localhost:8080/q/logging-manager?loggerName=com.acme.inventory.StockService' \
-H 'accept: application/json'
You'll get something like:
{
"name": "com.acme.inventory.StockService",
"configuredLevel": "DEBUG",
"effectiveLevel": "DEBUG"
}
When done troubleshooting, revert quickly to the original logging state without redeployment:
curl -X 'POST' \
'http://localhost:8080/q/logging-manager' \
-H 'accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'loggerName=com.acme.inventory.StockService&loggerLevel=OFF'
Instantly back to minimal, performant logging.
Using the Quarkus Dev UI
The Logging Manager integrates seamlessly with the Dev UI. Access it via your browser at:
http://localhost:8080/q/dev-ui/
Navigate to Logging Manager to visually configure your loggers.
This makes quick experiments effortless. Perfect during local development or staging debugging sessions.
Including the Logging Manager in OpenAPI
You can include the Logger Manager API in the OpenAPI document (and thus also Swagger UI). This needs to be enabled in application.properties like this:
quarkus.logging-manager.openapi.included=true
Securing the Logging Manager Endpoint
Quarkus Logging Manager endpoints provide significant control over your application's logging behavior, so exposing them publicly, especially in production, can lead to security risks.
Always:
Secure the Logging Manager endpoints using Quarkus security features (e.g., OpenID Connect, Basic Auth, or RBAC).
Restrict access to trusted roles (developers, admins).
Prefer using these endpoints in controlled environments (development, QA, staging).
Fortunately we can secure our endpoints using Quarkus' default security mechanism, as described in Security Overview. All you have to do is define your application.properties similar to this:
quarkus.http.auth.basic=true # If you want basic auth. Multiple auth mechanism are supported
quarkus.http.auth.policy.admin-access.roles-allowed=admin
quarkus.http.auth.permission.roles1.paths=/q/logging-manager
quarkus.http.auth.permission.roles1.policy=admin-access
General Recommendation on Developer Tools
While powerful, developer tools like Quarkus Dev UI and Logging Manager are generally not recommended for production environments. If production runtime adjustments are essential, ensure endpoints are strongly secured, access controlled, and potentially disabled by default. Tools intended primarily for developer convenience may inadvertently expose sensitive information or control.
Quick Recap
Here's what we've learned:
Logging is fundamental for troubleshooting.
Quarkus Logging Manager lets you adjust logging dynamically, avoiding costly redeployments.
You can control loggers via REST or visually through the Dev UI.
Always ensure endpoint security and limit developer tool exposure in production.
Wrap-Up
Logging should always work for you, not against you. Quarkus Logging Manager is the developer's Swiss army knife for logging—flexible, immediate, and intuitive.
Your next debugging session could go from panic to confident troubleshooting in seconds.
Ready to log smarter?