Logfire Winston Transport

Get started with Winston transport in 3 easy steps.

1. Install

Install Logfire Winston NPM packages:

npm install @logfire-sh/winston @logfire-sh/node

2. Set up Logfire client:

Set up Logfire Winston transport:

const winston = require('winston')
const { Logfire } = require('@logfire-sh/node');
const { LogfireTransport } = require('@logfire-sh/winston');

// Create a Logfire client
const logfire = new Logfire(`$SOURCE_TOKE`);

// Create a Winston logger - passing in the Logfire transport
const logger = winston.createLogger(
    {
        transports: [new LogfireTransport(logfire)],
    });

Replace $SOURCE_TOKEN with your source token. You can get your source tokens in your Logfire sources.

3. Start logging 🎉

logger.error('An Error Occured!!!');
logger.info('Structured logging message.', { obj: 'Superbike', color: 'pink'});

// Ensure that all logs are sent to Logfire
logfire.flush()

You should see your logs in Logfire → Live tail.


Winston version 3.2.1 or higher is required.