DEV Community

Sidhant Panda
Sidhant Panda

Posted on

A Discord transport for Winston Logger

I just published an npm package to send log messages directly to your Discord channel.

Check out winston-discord-transport on Github!

It's pretty straight-forward to use if your already use winston to manage server logs.

Install the package

$ npm i winston-discord-transport

Use the transport

import winston from "winston";
import DiscordTransport from "winston-discord-transport";

const logger = winston.createLogger({
  transports: [
    new DiscordTransport({
      webhook: "https:/your/discord/webhook",
      defaultMeta: { service: "my_node_service" },
      level: "warn"
    })
  ]
});

logger.log({
  level: "error",
  message: "Error intializing service",
  error: new Error()
});

If you provide an error in the log message, the transport will send the entire error stack to Discord, so you can pin point the location of error directly from the message.

Error message screenshot

Check out the README for more information!

Top comments (0)