Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #25

Merged
merged 2 commits into from
Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ npm install pino-elasticsearch -g
You can then use [Kibana](https://www.elastic.co/products/kibana) to
browse and visualize your logs.

## Use as a module

use pino-elasticsearch as a module is simple, use [pino-multi-stream](https://www.npmjs.com/package/pino-multi-stream) to send log to multi transport, for example:

```js
const pinoms = require('pino-multi-stream')
const pinoEs = require('pino-elasticsearch')({
host: '192.168.1.220',
index: 'zb',
port: '9200'
})

const logger = pinoms({
streams: [
{level: 'error', stream: process.stderr}, // an "error" level destination stream
{level: 'info', stream: process.stdout}, // an "info" level destination stream
{stream: pinoEs}
]
})


logger.info({'msg': {'info': 'info'}})
logger.debug('debug')
logger.warn('warn')
logger.error('error')

```

*** Notice, the `host` and `port` parameters of `pino-elasticsearch` are required ***

## Setup and Testing

Setting up pino-elasticsearch is easy, and you can use the bundled
Expand Down