Hey! These docs are for version 2021.3, which is no longer officially supported. Click here for the latest version, 2022.1!

Logging from Node.js

Node.js apps can log to Seq with the Bunyan logging framework

Logging with Winston

Winston is a popular node.js logging library with support for structured logging. Winston uses 'transports' to represent different log destinations including the usual console and file options. winston-seq is a Winston transport that allows Winston to write to Seq.

Getting started

npm install @datalust/winston-seq winston


Minimal example:

const winston = require('winston');
const { SeqTransport } = require('@datalust/winston-seq');

const logger = winston.createLogger({
  transports: [
    new SeqTransport({
      serverUrl: "https://your-seq-server:5341",
      apiKey: "your-api-key",
      onError: (e => { console.error(e) }),

Configuration with typical options:

const winston = require('winston');
const { SeqTransport } = require('@datalust/winston-seq');
// or import { SeqTransport } from '@datalust/winston-seq';

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.combine(  /* This is required to get errors to log with stack traces. See */
    winston.format.errors({ stack: true }),
  defaultMeta: { /* application: 'your-app-name' */ },
  transports: [
    new winston.transports.Console({
        format: winston.format.simple(),
    new SeqTransport({
      serverUrl: "https://your-seq-server:5341",
      apiKey: "your-api-key",
      onError: (e => { console.error(e) }),
      handleExceptions: true,
      handleRejections: true,

Send log events

Send structured log events, with properties that can be used later for filtering and analysis:"Hello {name}", {name: "World"});

Attach context by creating child loggers:

const taskLogger = logger.child({ activity: "purchase" });
    "User {user} purchase product {product} at ${price}", 
        user: "Millie Gilbert",
        product: "Yardtime Garden Shears",
        price: 29.99

A structured log event from Winston and winston-seq

Logging with Bunyan

The Bunyan library is a logger for JavaScript with wide platform support and good facilities for structured log messages. The bunyan-seq package is a plug-in for Bunyan that batches log events and posts the to the Seq HTTP ingestion API.

Getting started

First, install both the bunyan and bunyan-seq packages.

npm install --save bunyan
npm install --save bunyan-seq


When configuring the Bunyan logger, pass a Seq stream using createStream():

let bunyan = require('bunyan');
let seq = require('bunyan-seq');

var log = bunyan.createLogger({
    name: 'myapp',
    streams: [
            stream: process.stdout,
            level: 'warn',
            serverUrl: 'http://localhost:5341',
            level: 'info'
log.warn({lang: 'fr'}, 'Au revoir');

The createStream() method accepts a configuration object with the following parameters. No parameters are required.





The API Key to use when connecting to Seq


1048576 (1 MiB)

The maximum batch size to send to Seq (should not exceed Settings > System > Raw ingestion payload limit)


262144 (256 kiB)

The maximum event size to send to Seq; larger events will be dumped to stdout (should match Settings > System > Raw event body limit)


The Bunyan logging level for the stream



The time in milliseconds that the logger will wait for additional events before sending a batch to Seq


The Bunyan stream name, which can be used when configuring Bunyan filters


Log to console

A function to receive any errors raised when sending events to Seq



If true, error events raised by the stream will propagate as 'error' events on the Bunyan logger object.



The HTTP endpoint address of the Seq server

Message templates

You can specify property names as tokens in the log message to control how the event is rendered in Seq:{user: 'Alice'}, 'Hi, {user}!');

It is not necessary to specify tokens for all properties, but using this technique instead of string formatting will produce more easily machine-readable log events by associating the same template, and thus the same event id, with related events.


More Seq options for Node.js

Did this page help you?