LokiLogger — high-level logger with batching, redaction, and auto-flush
The LokiLogger is the recommended entry point for most use cases. It wraps LokiTransport with automatic batching, configurable redaction, and background flushing.
Entries are buffered in memory and flushed to Loki when either:
Batch size is reached (batchSize entries buffered)
Flush interval elapses (flushInterval ms since last flush)
flush() is called manually
dispose() is called (stops interval + final flush)
const logger = new LokiLogger({ batchSize: 50, // Flush every 50 entries flushInterval: 10000, // Or every 10 seconds});// Buffered — will flush when 50 entries or 10s passesfor (let i = 0; i < 100; i++) { logger.log({ line: `Event ${i}` });}