Transports

Configure multiple log destinations with different transports. Vestig supports console, HTTP, file, and Datadog out of the box.

NNode.jsServer
ConsoleTransport
Output logs to the console with colors and formatting

Configuration

new ConsoleTransport({
  level: 'debug',
  colors: true,
  structured: false, // Pretty print for dev
})

Features

Color-coded levelsPretty printingJSON mode for prod
HTTPTransport
Send logs to any HTTP endpoint with batching

Configuration

new HTTPTransport({
  endpoint: 'https://logs.example.com/ingest',
  batchSize: 100,
  flushInterval: 5000,
  headers: {
    'Authorization': 'Bearer ${API_KEY}',
  },
})

Features

Batch processingRetry with backoffCustom headers
FileTransport
Write logs to files with rotation and compression

Configuration

new FileTransport({
  filename: './logs/app.log',
  maxSize: '10mb',
  maxFiles: 5,
  compress: true, // gzip old files
})

Features

Log rotationGzip compressionSize limits
DatadogTransport
Send logs directly to Datadog Log Management

Configuration

new DatadogTransport({
  apiKey: process.env.DD_API_KEY,
  service: 'my-app',
  source: 'nodejs',
  tags: ['env:production'],
})

Features

Datadog integrationAutomatic taggingSource mapping
Multi-Transport Configuration
Send logs to multiple destinations simultaneously
typescript
import {
  createLogger,
  ConsoleTransport,
  HTTPTransport,
  FileTransport,
} from 'vestig'

const log = createLogger({
  level: 'debug',
  transports: [
    // Console for development
    new ConsoleTransport({
      enabled: process.env.NODE_ENV !== 'production',
      colors: true,
    }),

    // HTTP for log aggregation service
    new HTTPTransport({
      endpoint: process.env.LOG_ENDPOINT,
      batchSize: 50,
      headers: {
        'X-API-Key': process.env.LOG_API_KEY,
      },
    }),

    // File for local persistence
    new FileTransport({
      filename: './logs/app.log',
      maxSize: '50mb',
      maxFiles: 10,
    }),
  ],
})

// All transports receive every log
log.info('Application started', { version: '1.0.0' })
Common Transport Options
Options shared across all transport types
Result
level — Minimum log level
enabled — Toggle transport on/off
filter — Custom filter function
batchSize — Logs per batch
flushInterval — Auto-flush timing
maxRetries — Retry attempts

Key Features

  • Multiple Destinations — Send logs to console, files, HTTP, and Datadog simultaneously
  • Batch Processing — Efficient batching with configurable size and flush intervals
  • Retry Logic — Automatic retries with exponential backoff for network transports
  • Level Filtering — Each transport can have its own minimum log level
  • Custom Transports — Extend BatchTransport to create your own