winston-gelf-transporter
A Winston transporter for sending GELF messages to your Graylog server.
Setup
Installation
To install with npm
npm install winston-gelf-transporter
Importing
ES6 style
;
CommonJS
const WinstonGelfTransporter = ;
Configuration
You can create a new transporter as such
const transporter = ;
You can also pass a TransporterOptions
object to the constructor
const transporter = level: string // optional - logging level for the transporter silent: boolean // optional - true to turn off output handleExceptions: boolean version: string // Graylog communication version, default 1.1 host: string // Host for your graylog server, default 127.0.0.1 port: number // Port for your graylog server, default 12201 protocol: string // The input protocol for your GELF input, default 'udp' hostName: string // The name of the host for your Node.js app additional: Object // Additional defaults to add to your messages
Usage
All you need to do is add the transporter to your winston logger.
;; logger = winston; // 1. Log a stringlogger;// 2. Log an objectlogger;// 3. Log a string message with objectlogger;// 4. Log an errorlogger;// 5. Log an error with a messagelogger;// 6. Or log a message with an errorlogger;
The above logging statements will result in the following
1.2.3.4.5.6.