log4js-rest
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Rest Appender for log4js-node

Sends [log] events to a [REST] api. This is an optional appender for use with log4js.

Configuration

npm install log4js
npm install log4js-rest
npm install os

Example

import * as log4js from 'log4js';
import { Log4JsRestAppender } from 'log4js-rest';
import * as os from 'os';

log4js.configure({
    appenders: {
        consoleAppender: { type: 'console' },
        restAppender: {
            type: Log4JsRestAppender,
            url: 'https://your.rest-api.server/log-api/',
            appName: 'suppliers',
            level: 'INFO',
            env: { host: os.hostname(), type: os.platform(), hostname: os.hostname(), },
            minLevel: log4js.levels.WARN,
            maxLevel: log4js.levels.FATAL,
            collectionName:'your_collection_name_in_db'
        }
    },
    categories: {
        default: {
            appenders: ['consoleAppender', 'restAppender'],
            level: 'DEBUG'
        }
    }
});
const logger = log4js.getLogger();
logger.warn('App start');

This configuration will send all messages to the url address.

Package Sidebar

Install

npm i log4js-rest

Weekly Downloads

1

Version

1.2.1

License

ISC

Unpacked Size

20.2 kB

Total Files

13

Last publish

Collaborators

  • jirvra