Logs and metrics
Logging
Send logs from every app with one key, then search, filter and follow them live, with levels, namespaces and apps.
Send logs from your code with an SDK or one HTTP request, and they show up in Logs within a second. Every app of a domain sends with the same ingest key, and you search them all in one place.
Send logs
Copy the ingest key from Settings, keep it in LOGDASH_API_KEY and pass it to the SDK. Without a key, the SDKs write to the console only, which is handy in local development.
import { Logdash } from '@logdash/node';
const logdash = new Logdash(process.env.LOGDASH_API_KEY);
logdash.info('Application started successfully');
logdash.error('An unexpected error occurred');
logdash.warn('Low disk space warning'); import os
from logdash import create_logdash
logdash = create_logdash({"api_key": os.environ["LOGDASH_API_KEY"]})
logger = logdash.logger
logger.info("Application started successfully")
logger.error("An unexpected error occurred")
logger.warn("Low disk space warning") package main
import (
"context"
"os"
"time"
"github.com/logdash-io/go-sdk/logdash"
)
func main() {
ld := logdash.New(logdash.WithAPIKey(os.Getenv("LOGDASH_API_KEY")))
logger := ld.Logger
logger.Info("Application started successfully")
logger.Error("An unexpected error occurred")
logger.Warn("Low disk space warning")
// Every level has an ...F() counterpart, like fmt.Printf.
logger.InfoF("Processing %v of %v item", 1, 10)
// Shutdown waits for every enqueued log, metric and event to flush.
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
ld.Shutdown(ctx)
} logdash.Info("This is info message");
logdash.Warn("This is warn message");
logdash.Error("This is an error message");
logdash.Debug("This is a debug message"); 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"
)); let (logger, _) = logdash::create_logdash(logdash::Config::default());
// Send an info log message
logger.info("Rust SDK example"); logger.info('Application started successfully')
logger.error('An unexpected error occurred')
logger.warn('Low disk space warning') $logger->error('Application error occurred');
$logger->warn('This is a warning message');
$logger->info('User logged in successfully'); curl -X POST https://api.logdash.io/logs \
-H "project-api-key: $LOGDASH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Application started successfully", "level": "info", "createdAt": "'"$(date -u +%FT%TZ)"'"}' Most SDKs send logs in the background. In a short-lived process, such as a cron job or a serverless function, flush before the process exits so the last logs are sent. The page of your SDK shows how.
Levels
Every log has one of seven levels. The SDKs have a method for each, and the HTTP API takes the name in level.
| Level | Use it for |
|---|---|
error | Something failed and needs attention. |
warning | Something looks wrong but still works. The SDK methods are called warn. |
info | What your app does, such as a started job or a new signup. |
http | Requests your app serves or makes. |
verbose | More detail than info. |
debug | Detail for debugging. |
silly | Everything else. |
Namespaces
A namespace groups the logs of one part of your app, such as auth or billing, so you can filter by it. In the Node.js SDK, withNamespace returns a logger that adds the namespace to every log. Over HTTP, send it in namespace, up to 255 characters.
const authLogdash = logdash.withNamespace('auth');
authLogdash.info('User logged in');
authLogdash.error('Authentication failed'); Apps
When more than one program sends logs, name each with the app option, such as api or worker. Logdash adds the app with its first log, and Logs gets an App filter. See Apps.
const logdash = new Logdash(process.env.LOGDASH_API_KEY, { app: 'worker' }); Search and filter
The Logs page shows the newest logs first, with a chart of log volume above them.
- Search logs finds logs that contain every word you type, in any case.
- Errors and Warnings show only logs of that level, in one click.
- The filters narrow by App, Level, Namespace and Time range. Hold ⌘ or Shift to pick more than one value.
- Time range offers the last 15 minutes up to the last 30 days, or a Custom range. Ranges longer than the retention of your plan show Upgrade.
- Drag across the volume chart to zoom into that time.
- The clock button switches between relative and exact times.
Read a log
Click a log to open it with its full message, level, namespace and app. The arrow keys move to the previous or next log of the same level, so you can step through every error in a row. Press Esc to close it.
Live tail
Without a time range, new logs appear as they arrive and match your search and filters. Picking a time range stops following, and clearing it starts again. The page also pauses while its tab is hidden.
Limits
- Messages longer than 4,096 characters are cut.
- Each app can send a fixed number of logs per hour. The hour starts with the first log, and logs past the limit get
429 Rate limit exceededuntil it ends. - Logs are deleted when they are older than the retention of your plan.
| Limit | Hobby | Builder | Pro |
|---|---|---|---|
| Retention | 1 day | 7 days | 30 days |
| Logs per app per hour | 10,000 | 25,000 | 50,000 |
| Logs kept per app | 240k | 4.2M | 36M |
For every field, the batch endpoint and the read API, see HTTP API.