winston-transport-http-stream
v0.1.4
Published
custom winston transport to stream logs to http endpoint
Downloads
4,759
Readme
winston-transport-http-stream
This library will push your Winston logger information to an external http endpoint e.g. central log collection. When the request fails the logging request won't be send again.
Installation
npm install winston-transport-http-stream
or
yarn add winston-transport-http-stream
Usage
Example
The options
parameter object is directly passed to node's http library but you can add also the url
property that
will be parsed and automatically set the relevant options for http.
You can see all options in the official docs here.
const winston = require('winston')
const HttpStreamTransport = require('winston-transport-http-stream')
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
new HttpStreamTransport({
url: 'https://yourdomain.com/log'
})
]
})
logger.info('hello')