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

1.0.30 • Public • Published

log4js-promises

This is a next possible conversion of the log4j framework to work with node. It is a also alternative for original template for this project log4js. Main differences between log4js and this project is, that this is full promised based and strongly typed project (minimize of using any) full ready for esnext.

The full documentation is available here.

Internal implementation of appenders:

  • console
  • file
  • std-err
  • loglevel
  • custom

Example of custom appenders:

Simple example

if (require.main === module) {
    configureLogger({
        appenders: {
            consoleAppender: {
                type: eCoreAppenderType.console,
                layout: {
                    type: 'COLORED_CONSOLE',
                    appName: 'appName',
                    source: 'develop',
                    static: {
                        env: {
                            host: 'config.http.balancerHost',
                        },
                    },
                    stringFormat: {
                        colors: true,
                    },
                },
            },
            consoleAppenderByLevel: {
                type: eCoreAppenderType.logLevelFilter,
                appender: 'consoleAppender',
                monLevel: logLevels.DEBUG,
                maxLevel: logLevels.ERROR,
            },
        },
        categories: {
            default: {
                appenders: ['consoleAppenderByLevel'],
            },
        },
    })
        .then(() => {
            const logger = getLogger();
            logger.debug('This is a message');
        })
        .catch((err) => {
            console.debug(err);
        });
}
[2024-01-28T16:56:57.745] [DEBUG] [default] - "This is a message"

Readme

Keywords

none

Package Sidebar

Install

npm i log4js-node-next

Weekly Downloads

1

Version

1.0.30

License

ISC

Unpacked Size

129 kB

Total Files

71

Last publish

Collaborators

  • jirvra