Configure multiple log destinations
Output logs to the console with colors and formatting
new ConsoleTransport({
level: 'debug',
colors: true,
structured: false,
})Send logs to any HTTP endpoint with batching
new HTTPTransport({
endpoint: 'https://logs.example.com/ingest',
batchSize: 100,
flushInterval: 5000,
headers: { 'Authorization': 'Bearer ${API_KEY}' },
})Write logs to files with rotation and compression
new FileTransport({
filename: './logs/app.log',
maxSize: '10mb',
maxFiles: 5,
compress: true,
})Send logs directly to Datadog Log Management
new DatadogTransport({
apiKey: process.env.DD_API_KEY,
service: 'my-app',
source: 'nodejs',
tags: ['env:production'],
})Send errors and logs to Sentry for monitoring
new SentryTransport({
dsn: process.env.SENTRY_DSN,
environment: 'production',
release: '1.0.0',
minLevel: 'warn',
})import {
createLogger,
ConsoleTransport,
HTTPTransport,
FileTransport,
SentryTransport,
} 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,
}),
// File for local persistence
new FileTransport({
filename: './logs/app.log',
maxSize: '50mb',
}),
// Sentry for error monitoring (warn+ only)
new SentryTransport({
dsn: process.env.SENTRY_DSN,
minLevel: 'warn',
}),
],
})
// All transports receive every log
log.info('Application started', { version: '1.0.0' })