https://github.com/datalust/bunyan-seq
A Bunyan stream to send events to Seq
https://github.com/datalust/bunyan-seq
Last synced: 10 months ago
JSON representation
A Bunyan stream to send events to Seq
- Host: GitHub
- URL: https://github.com/datalust/bunyan-seq
- Owner: datalust
- License: apache-2.0
- Created: 2016-03-28T02:14:31.000Z (about 10 years ago)
- Default Branch: dev
- Last Pushed: 2023-05-03T03:51:20.000Z (about 3 years ago)
- Last Synced: 2024-06-18T17:02:12.962Z (almost 2 years ago)
- Language: JavaScript
- Homepage: https://datalust.co/seq
- Size: 271 KB
- Stars: 11
- Watchers: 7
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bunyan-seq   [](https://www.npmjs.com/package/bunyan-seq)
A Bunyan stream to send events to [Seq](https://datalust.co/seq). Tested with Node.js versions 4.2.2 and up.
> [!WARNING]
>
> This package is deprecated due to inactivity in the upstream Bunyan project, and no further updates are planned at this time.
## Usage
First, install `bunyan-seq` as a global tool:
```shell
npm install -g bunyan-seq
```
Then, pipe the output of your bunyan-enabled app to it:
```shell
node your-app.js | bunyan-seq --serverUrl http://localhost:5341 --apiKey 1234567890 --property application=ExampleApp
```
`bunyan-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 bunyan) 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
### Structured logging with message templates
You can specify property names as tokens in the log message to control how the event is rendered in Seq:
```js
// Seq will render this as 'Hi, Alice!'
log.info({ user: 'Alice' }, 'Hi, {user}!');
```
The full message template syntax is documented [here](https://messagetemplates.org).
### Capturing other output
To enable capture of output not formatted through bunyan 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> >(bunyan-seq --logOtherAs Error --serverUrl http://localhost:5341 --apiKey 1234567890) `
> >(bunyan-seq --logOtherAs Information --serverUrl http://localhost:5341 --apiKey 1234567890)
```
## In-process usage
Use the `createStream()` method to create a Bunyan stream configuration, passing `serverUrl`, `apiKey` and batching parameters.
```js
let bunyan = require('bunyan');
let seq = require('bunyan-seq');
var log = bunyan.createLogger({
name: 'myapp',
streams: [
{
stream: process.stdout,
level: 'warn'
},
seq.createStream({
serverUrl: 'http://localhost:5341',
level: 'info',
reemitErrorEvents: true,
onError: (e) => {
console.error('[SeqStreamCustomError] failed to log events:', e);
}
})
]
});
log.info('hi');
log.warn({ lang: 'fr' }, 'au revoir');
```
Read the [complete documentation](https://docs.datalust.co/docs/using-nodejs).