@gogoout/winston-logstash-ts
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

winston-logstash-ts

A winston logstash transport to UDP protocol in Typescript. Rewrite from https://github.com/liuyanjie/winston-logstash-transport

Dependencies

  • logform: "^2.1.2",
  • winston: "^3.3.3",
  • winston-transport: "^4.4.0"

Installation

  • Install to your project using npm -i winston-logstash-ts or yarn add winston-logstash-ts

Example

  • Manually create logstash transport, then add to an existing winston instance
import { LogstashTransport } from "winston-logstash-ts"
.
.
const logstash = new LogstashTransport({
    host: "logstash.hostname.or.ip",
    port: 11200,
    protocol: "udp", //default is udp, support tcp connection as alternative
    format: logform.format.combine(
        logform.format.timestamp(),
        logform.format.logstash(),
    )
});
winston.add(logstash);
.
.
  • Use LogstashTransport.createLogger() static method to create winston logger with logstash transport
import { LogstashTransport } from "winston-logstash-ts"
.
.
const logger = LogstashTransport.createLogger("<APP_NAME>", {
    host: "logstash.hostname.or.ip",
    port: 11200,
    protocol: "udp", //default is udp, support tcp connection as alternative
    format: logform.format.combine(
        logform.format.timestamp(),
        logform.format.logstash(),
    )
});

The option type is LogstashOption (https://github.com/HuskyMoonMoon/winston-logstash-ts/blob/master/src/LogstashOption.ts), which is extended from winston.LoggerOption

Package Sidebar

Install

npm i @gogoout/winston-logstash-ts

Weekly Downloads

0

Version

0.2.4

License

MIT

Unpacked Size

20.6 kB

Total Files

13

Last publish

Collaborators

  • gogoout