npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

graylog-loging

v1.1.1

Published

This is a node js loging middleware for graylog. It has been designed for request and response loging.

Downloads

80

Readme

graylog-loging

This is a node js loging middleware for graylog. It has been designed for request, response and error loging.

What is GrayLog

GrayLog is an open source log management application. See details https://www.graylog.org/

Installation

  npm install graylog-loging --save

Usage

If you want to set your graylog server host informations, you need to init graylog-loging module in your server.js file.

var graylog = require('graylog-loging');
graylog.init({
  graylogPort: 12201,
  graylogHostname: '192.168.1.5'
});

Init Options

Here is the default values for graylog-loging options. You can set this options on init.

  var options = {
    graylogPort : 12201, //Graylog Server Port
    graylogHostname : '127.0.0.1', //Graylog Server Host
    connection: 'wan', //Graylog Server Connection,
    maxChunkSizeWan : 1420,
    maxChunkSizeLan : 8154,
    logRequest : true, //If setted false, it's not log request logs
    requestLogLevel : 'info', //Log level for request logs
    logResponse : true, //If setted false, it's not log response logs
    responseLogLevel : 'info', //Log level for response logs
    environment : 'live', //You can set your environmen like development, prelive or etc
    applicationName : 'default', //You can set your application name like authentication-api
    enableUncaughtException : true //It will log your uncaught exceptions
  };

Log Request

You can set your request log in server.js for whole application. But it will not log your query and params parameters in request.

app.use(graylog.logRequest);

If you want to catch your params and query paramters please set request log in your route level.

app.get('/my-route', graylog.logRequest,function(req, res, next){
  //Your-code-here
});

It will log;

  • authorization : Authorization header
  • body : Request body
  • environment : live, prelive, development or whatever you set on init config
  • facility : 'node.js'
  • ip : ip address
  • log-level : 'info'
  • message : 'Request for /my-route'
  • method : 'GET|POST|PUT|DELETE' etc.
  • pair-id : Unique id for request
  • params : Params object
  • query : Query object
  • source : application name which you set on init config
  • timestamp : '2017-04-19T10:02:51.535Z'
  • type : 'request' It describes log type
  • url : 'Request url address'
  • user-agent : 'Mozilla/5.0 ....'

Log Response

It designed for log your response message. You can set it on your server.js file.

app.use(log.logResponse);

It will log;

  • body : Response body
  • environment : live, prelive, development or whatever you set on init config
  • facility : 'node.js'
  • log-level : 'info'
  • message : "Response log for '/my-route'"
  • method : 'GET|POST|PUT|DELETE' etc.
  • pair-id : Unique id for request
  • source : application name which you set on init config
  • statusCode : Response status code
  • timestamp : 2017-04-19T08:31:39.667Z
  • type : 'response' It describes log type

Handle Errors

You can set this middleware after you set your routes. It will catch express errors and create log.

app.use(log.handleErrors);

It will log;

  • environment : live, prelive, development or whatever you set on init config
  • error : Error stack
  • facility : 'node.js'
  • log-level : 'error'
  • message : "Error log for '/my-route'"
  • method : 'GET|POST|PUT|DELETE' etc.
  • pair-id : Unique id for request
  • source : application name which you set on init config
  • timestamp : 2017-04-19T08:31:39.667Z
  • type : 'error-handler' It describes log type

Uncaught Exception Loging

It has been designed for creating logs on your node application crashes. If you don't want to use Uncaught Exception Loging, you can set enableUncaughtException : false in your init config.

graylog.init({
  enableUncaughtException : false
});

What Is Pair Id?

It's a unique timestamp that creating on request loging. So you can see which response log belongs to request log. They have the same pair-id. When you search pair id in your graylog client application, you can see reqest log and response log for a client request/response proccess.

License

MIT

Author

Melih Korkmaz [email protected].