https://github.com/datalust/pino-seq
A stream to send Pino events to Seq
https://github.com/datalust/pino-seq
pino seq
Last synced: about 1 month ago
JSON representation
A stream to send Pino events to Seq
- Host: GitHub
- URL: https://github.com/datalust/pino-seq
- Owner: datalust
- License: apache-2.0
- Created: 2019-10-29T01:03:32.000Z (almost 6 years ago)
- Default Branch: dev
- Last Pushed: 2024-03-26T22:20:41.000Z (over 1 year ago)
- Last Synced: 2024-11-30T11:37:33.166Z (10 months ago)
- Topics: pino, seq
- Language: JavaScript
- Size: 226 KB
- Stars: 11
- Watchers: 5
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pino-seq   [](https://www.npmjs.com/package/pino-seq)
A stream to send [Pino](https://github.com/pinojs/pino) events to [Seq](https://datalust.co/seq). Tested with Node.js versions 18.x 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](https://getpino.io).
This will look something like:
```js
const logger = (await import('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:
```shell
npm install -g pino-seq
```Then, pipe the output of your Pino-enabled app to it:
```shell
node your-app.js | pino-seq --serverUrl http://localhost:5341 --apiKey 1234567890 --property applicationName=PinoSeqExampleApp
````pino-seq` accepts the following parameters:
- `serverUrl` - this is the base URL of your Seq server; if omitted, the default value of `http://localhost:5341` will be used
- `apiKey` - your Seq API key, if one is required; the default does not send an API key
- `logOtherAs` - log other output (not formatted through pino) to seq at this loglevel. Useful to capture messages if the node process crashes or smilar.
- `property` - add additional properties to all logs sent to Seq#### 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:
```shell
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.
```js
import pino from 'pino';
import pinoToSeq from '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.