0.0.7 • Published 5 years ago

alog4js v0.0.7

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

alog4js Build Status NPM Version

This is a wrappers of the log4js-node, and we add functions for dynamic layout setting.

The init function parameter is an Array of domain list, and the domain list only need to set the top level

We can use its sublevel without further setting, thanks for Gareth Jones(log4js-node)

prerequisite

nodejs 10.12.0 or bigger.

installation

npm install alog4js

usage

Initialize:

var log4js = require('alog4js');
log4js.init(['default','Foo_toplevel1','Foo_toplevel2'...])
var logger = log4js.getLogger(); //now you can use the logger with default tag

RUN with argument:

LEVEL=info SHOW=* node main.js

Dynamic Layout setting:

Implement your REST API and run these code properly.

And your can update server log layout setting online.

  • dynamic change log level
logger.level = 'debug'; // ['trace','debug','info','warn','error','fatal']
  • dynamic change specific log domain with log level
//show is the variable format like Run Argument SHOW, check Example for further information
log4js.update(show, level); // log4js.update("DB.pool", "trace");
  • trace the log by file
less -R trace.log

or install the colortail (recommended)

colortail -f trace.log

Demo

run demo on your machine alog4js-demo

or look demo video on youtube

Video

Example

  • Default run with LEVEL=info, SHOW=*

    node examples/main.js

    Demo1

  • set log level at 'debug', and show log belongs 'DB'.

    LEVEL=debug SHOW=DB node examples/main.js

    Demo2

  • set log level at 'trace', and show log belongs 'DB.index' only.
    LEVEL=trace SHOW=DB.index node examples/main.js

    Demo3

  • set log level at 'error', and show log belongs 'default' or 'DB' or 'modules.insert'.

    LEVEL=error SHOW=default,DB,modules.insert node examples/main.js

    Demo4

  • set log level at 'warn', and show log belongs 'default' or 'DB.index'.

    LEVEL=warn SHOW=default,DB.index node examples/main.js

    Demo5

License

The original log4js-node was distributed under the Apache 2.0 License, and so is this. I've tried to keep the original copyright and author credits in place, except in sections that I have rewritten extensively.

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago