Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@log4js-node/gelf

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@log4js-node/gelf

GELF Appender for log4js-node

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
840
decreased by-19.08%
Maintainers
1
Weekly downloads
 
Created
Source

Log4JS - GELF appender

This is an optional appender for log4js-node.

npm install @log4js-node/gelf

The GELF appender supports sending log messages over UDP to a GELF compatible server such as Graylog. It uses node's core UDP support and does not require any other dependencies. If you use this appender, remember to call log4js.shutdown when your application terminates, so that all messages will have been sent to the server and the UDP socket can be closed. The appender supports passing custom fields to the server in both the config, and in individual log messages (see examples below).

Configuration

  • type - @log4js-node/gelf
  • host - string (defaults to localhost) - the gelf server hostname
  • port - integer (defaults to 12201) - the port the gelf server is listening on
  • hostname - string (defaults to OS.hostname()) - the hostname used to identify the origin of the log messages.
  • facility - string (optional)
  • customFields - object (optional) - fields to be added to each log message; custom fields must start with an underscore.

Example (default config)

log4js.configure({
  appenders: {
    gelf: { type: '@log4js-node/gelf' }
  },
  categories: {
    default: { appenders: ['gelf'], level: 'info' }
  }
});

This will send log messages to a server at localhost:12201.

Example (custom fields in config)

log4js.configure({
  appenders: {
    gelf: { type: '@log4js-node/gelf', host: 'gelf.server', customFields: { '_something': 'yep' } }
  },
  categories: {
    default: { appenders: ['gelf'], level: 'info' }
  }
});

This will result in all log messages having the custom field _something set to 'yep'.

Example (custom fields in log message)

log4js.configure({
  appenders: {
    gelf: { type: '@log4js-node/gelf', customFields: { '_thing': 'isathing' } }
  },
  categories: {
    default: { appenders: ['gelf'], level: 'info' }
  }
});
const logger = log4js.getLogger();
logger.error({ GELF: true, _thing2: 'alsoathing' }, 'oh no, something went wrong');

This will result in a log message with the custom fields _thing and _thing2. Note that log message custom fields will override config custom fields.

Keywords

FAQs

Package last updated on 11 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc