SDKs
SDKs
Official open-source SDKs for Node.js, Python, Go, .NET, Java, Rust, Ruby and PHP that send logs and metrics to Logdash.
The SDKs send logs and metrics from your servers, workers and scripts. They are open source and work the same way in every language: create a client with your ingest key, then call a method per log level and per metric operation.
Install
npm install @logdash/node pip install logdash go get github.com/logdash-io/go-sdk/logdash dotnet add package Logdash // build.gradle
dependencies {
implementation 'io.logdash:logdash:0.2.0'
} cargo add logdash gem install logdash composer require logdash/php-sdk Send your first log
Copy the ingest key from Settings of your domain and keep it in LOGDASH_API_KEY.
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'); What every SDK does
- Sends logs at the seven levels, from
errortosilly. - Sets a metric or changes it by a number. See Set or change.
- Sends events to web analytics, next to the visits of your website.
- Names the app that sends, such as
apiorworker. See Apps.
No SDK for your language
Any language that makes HTTP requests can send logs and metrics. See the HTTP API.
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)"'"}' The SDKs are for servers. To measure the visitors of a website, add the web analytics tracker instead.