alog4js v0.0.7
alog4js

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 alog4jsusage
Initialize:
var log4js = require('alog4js');
log4js.init(['default','Foo_toplevel1','Foo_toplevel2'...])
var logger = log4js.getLogger(); //now you can use the logger with default tagRUN with argument:
LEVEL=info SHOW=* node main.jsDynamic 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.logor install the colortail (recommended)
colortail -f trace.logDemo
run demo on your machine alog4js-demo
or look demo video on youtube
Example
Default run with LEVEL=info, SHOW=*
node examples/main.jsset log level at 'debug', and show log belongs 'DB'.
LEVEL=debug SHOW=DB node examples/main.js
- set log level at 'trace', and show log belongs 'DB.index' only.
LEVEL=trace SHOW=DB.index node examples/main.js
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.jsset log level at 'warn', and show log belongs 'default' or 'DB.index'.
LEVEL=warn SHOW=default,DB.index node examples/main.js
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.
