Skip to content

jksdua/bunyan-logzio

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bunyan-logzio

A bunyan stream to send logs through to logzio.

Configuration

When configuring bunyan-logzio as a stream for bunyan, you need to pass in a logzio logger.

For example:

var logzioLogger = logzio.createLogger({
	protocol: 'https',
	token: config.get('logzio.token'),
	type: config.get('logzio.type.events')
});

Please note: auth values are NOT required to simply send logs through to logzio.

Usage

This is a basic usage example.

var bunyan = require('bunyan'),
	Bunyan2Logzio = require('bunyan-logzio').Bunyan2Logzio,
	logger;

// create the logger
logger = bunyan.createLogger({
	name: 'logziolog',
	streams: [
		{
			type: 'raw',
			stream: new Bunyan2Logzio(logzioLogger)
		}
	]
});

logger.info({});

Please note: you MUST define type: 'raw' as bunyan-logzio expects to recieve objects so that certain values can be changed as required by logzio (i.e. time to timestamp).

Express logging

This is an example of using bunyan-logzio to store express.js request logs.

var path = require('path'),
	bunyan = require('bunyan'),
	serializerRequest = require('../lib/serializer-request'),
	Bunyan2Logzio = require('bunyan-logzio').Bunyan2Logzio,
	request;

// create the logger
request = bunyan.createLogger({
	name: 'request',
	serializers: { req: bunyan.stdSerializers.req },
	streams: [
		{
			type: 'raw',
			stream: new Bunyan2Logzio(logzioLogger)
		}
	]
});

// export the middleware
module.exports = function () {

	return function (req, res, next) {

		// move on straight away
		next();

		// log this request
		request.info({
			req : req,
			production: process.env.NODE_ENV === 'production'
		});

	}

}

Changes

About

A bunyan stream to send logs through to logzio

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.0%
  • Makefile 2.0%