Quick Start
Get up and running with Timberlogs in under 5 minutes.
1. Get Your API Key
Sign up at app.timberlogs.dev and create an organization. Navigate to Settings > API Keys and create a new key.
Your API key will look like: tb_live_xxxxxxxxxxxxx
2. Initialize the Client
import { createTimberlogs } from 'timberlogs-client'
const timber = createTimberlogs({
source: 'my-app', // Your app/service name
environment: 'production', // development, staging, or production
apiKey: process.env.TIMBER_API_KEY,
})3. Send Your First Log
// Simple info log
timber.info('Application started')
// Log with data
timber.info('User signed in', {
userId: 'user_123',
email: 'user@example.com'
})
// Log a warning
timber.warn('Rate limit approaching', {
current: 950,
limit: 1000
})
// Log an error with stack trace
try {
await riskyOperation()
} catch (error) {
timber.error('Operation failed', error)
}4. View in Dashboard
Head to app.timberlogs.dev and select your organization. Your logs will appear in the Logs view within seconds.
5. Flush on Exit (Important!)
The SDK batches logs for efficiency. Make sure to flush before your process exits:
// Before shutdown
await timber.flush()
// Or use disconnect which flushes automatically
await timber.disconnect()Example: Express.js
import express from 'express'
import { createTimberlogs } from 'timberlogs-client'
const app = express()
const timber = createTimberlogs({
source: 'api-server',
environment: process.env.NODE_ENV || 'development',
apiKey: process.env.TIMBER_API_KEY,
})
app.use((req, res, next) => {
timber.info('Request received', {
method: req.method,
path: req.path,
ip: req.ip,
})
next()
})
app.get('/health', (req, res) => {
res.json({ status: 'ok' })
})
// Graceful shutdown
process.on('SIGTERM', async () => {
await timber.flush()
process.exit(0)
})
app.listen(3000)Next Steps
- Learn about all configuration options
- Explore the SDK reference
- Track user flows with Flow tracking
Last updated on