Logfire Bunyna Stream

Get started with Bunyna transport in 3 easy steps.

1. Install

Install Logfire Bunyan NPM packages:

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

2. Set up Logfire client:

Set up Logfire Bunyan stream:

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

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

// Create Bunyan logger
const logger = bunyan.createLogger(
    {
        name: 'Example logger',
        level: 'debug',
        streams: [
            {
                stream: new LogfireStream(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({
    obj: 'Superbike',
    color: 'pink'
}, 'Structured logging message.');

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

You should see your logs in Logfire → Live tail.


Bunyan version 2.0.0 or higher is required.