Skip to content

liangwp/log4js-node-telegramAppender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TelegramAppender - for log4js-node

Pre-requisites:

  • registered a telegram bot
  • telegram bot token
  • put the bot in a chat group
  • chat id of the group
  • reference: Telegram Bot API

Install peer dependency log4js:

npm install --save log4js

Install log4js-node-telegramAppender:

npm install --save "https://github.com/liangwp/log4js-node-telegramAppender/tarball/master"

Sample usage:

'use strict';

const log4js = require("log4js");
log4js.configure({
    appenders: {
        colouredConsole: { type: 'stdout' },
        telegramAlert: {
            type: 'log4js-node-telegramAppender',
            silentAlertLevel: 'info',
            audioAlertLevel: 'error',
            bottoken: <token>,
            botchatid: <chatid>
        }
    },
    categories: { default: { appenders: ['colouredConsole', 'telegramAlert'], level: 'debug' } }
})

var logger = log4js.getLogger("TEST");

logger.debug(`This logs to console only`);
logger.info(`This logs to console and telegram, without telegram notification sound`);
logger.error(`This logs to console and telegram, with telegram notification sound`);

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published