datalust / pino-seq

A stream to send Pino events to Seq
Apache License 2.0
11 stars 10 forks source link
pino seq

pino-seq Build Publish NPM

A stream to send Pino events to Seq. Tested with Node.js versions 4.2.2 and up.

Out-of-process (transport) usage recommended

First, install and use pino in your Node.js app, following the instructions in the Pino documentation.

This will look something like:

const logger = require('pino')();
logger.info('Hello, World!');

Pino will, by default, write newline-delimited JSON events to STDOUT. These events are piped into the pino-seq transport.

First, install pino-seq as a global tool:

npm install -g pino-seq

Then, pipe the output of your Pino-enabled app to it:

node your-app.js | pino-seq --serverUrl http://localhost:5341 --apiKey 1234567890 --property applicationName=PinoSeqExampleApp

pino-seq accepts the following parameters:

Capturing other output

To enable capture of output not formatted through pino use the logOtherAs parameter. It's possible to use different settings for STDOUT/STDERR like this, when using bash:

node your-app.js 2> >(pino-seq --logOtherAs Error --serverUrl http://localhost:5341 --apiKey 1234567890) > >(pino-seq --logOtherAs Information --serverUrl http://localhost:5341 --apiKey 1234567890)

In-process (stream) usage

Use the createStream() method to create a Pino stream configuration, passing serverUrl, apiKey and batching parameters.

let pino = require('pino');
let pinoToSeq = require('pino-seq');

let stream = pinoToSeq.createStream({ serverUrl: 'http://localhost:5341' });
let logger = pino({ name: 'pino-seq example' }, stream);

logger.info('Hello Seq, from Pino');

let frLogger = logger.child({ lang: 'fr' });
frLogger.warn('au reviour');

Acknowledgements

Originally by Simi Hartstein and published as simihartstein/pino-seq; maintainership transferred to Datalust at version 0.5.