Seq Logging for JavaScript

3.0.0 · active · verified Wed Apr 22

seq-logging is a JavaScript library designed to send structured log events to the Seq HTTP ingestion API. It is currently at version 3.0.0 and serves as a low-level client, primarily intended for use by other logging frameworks and their respective Seq transports (e.g., winston-seq, pino-seq, bunyan-seq, @tsed/logger-seq), rather than for direct application interaction. The library handles asynchronous batching of log events based on payload size and provides mechanisms to ensure all buffered events are sent upon application exit or explicit flushing. Its key differentiator is acting as the foundational communication layer for Seq within the JavaScript ecosystem, offering both Node.js and browser-specific builds, and explicitly supports ESM.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a Seq Logger and emits a structured log event with properties, demonstrating basic usage and proper shutdown.

import process from 'process';
import { Logger } from 'seq-logging';

const logger = new Logger({
    serverUrl: process.env.SEQ_SERVER_URL ?? 'http://localhost:5341',
    apiKey: process.env.SEQ_API_KEY ?? undefined, // Optional
    requestTimeout: 30000 // default to 30s
});

logger.emit({
    timestamp: new Date(),
    level: 'Information',
    messageTemplate: 'Hello from {appName}! It is {currentTime}.',
    properties: {
        appName: 'MySeqApp',
        currentTime: new Date().toISOString(),
        user: process.env.USERNAME ?? 'anonymous'
    }
});

// Ensure all buffered events are sent before exiting
logger.close().then(() => console.log('Logger closed successfully.'));

view raw JSON →