Java SDK
Install the Logdash Java SDK, send your first log and your first metric.
Install the package, paste your API key and the first log lands in the dashboard within a second. Everything below is copied from the Java SDK README.
Install
// build.gradle
dependencies {
implementation 'io.logdash:logdash:0.2.0'
} Initialise
Create a project in Logdash, copy its API key and keep it in an environment variable. The key identifies the project the data lands in.
import io.logdash.sdk.Logdash;
var logdash = Logdash.builder()
.apiKey(System.getenv("LOGDASH_API_KEY"))
.build();
var logger = logdash.logger();
var metrics = logdash.metrics(); Send a log
import java.util.Map;
logger.info("Application started");
logger.error("Database connection failed");
// Structured logging with context
logger.info("Payment processed", Map.of(
"userId", 12345,
"amount", 29.99,
"currency", "USD"
)); Send a metric
Metrics are named numbers. Set one to an absolute value or mutate it by a delta, and Logdash charts the history.
// Gauges - track current values
metrics.set("active_users", 1_250);
// Counters - track events and occurrences
metrics.mutate("api_requests", 1); Works with
- Spring Boot
- Quarkus
- Micronaut
- Standalone apps
FAQ
How do I install it with Maven instead of Gradle?
Add the Maven Central coordinates to your `pom.xml`: groupId `io.logdash`, artifactId `logdash`, version `0.2.0`.
Which Java versions are supported?
Java 17 and up. The SDK is tested on 17, 21 and 22.
Do logging calls block the request thread?
No. The SDK is async and calls return immediately. Defaults are a 15000 ms request timeout, 3 retries and 10 concurrent requests; call `logdash.flush()` and `logdash.close()` before shutdown.