The full documentation is available here.
There have been a few changes between log4js 1.x and 2.x (and 0.x too). You should probably read this migration guide if things aren't working.
Out of the box it supports the following features:
npm install log4js
var log4js = ;var logger = log4js;loggerlevel = 'debug';logger;
By default, log4js will not output any logs (so that it can safely be used in libraries). The
level for the
default category is set to
OFF. To enable logs, set the level (as in the example). This will then output to stdout with the coloured layout (thanks to masylum), so for the above you would see:
[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages
See example.js for a full example, but here's a snippet (also in
const log4js = ;log4js;const logger = log4js;logger;logger;logger;logger;logger;logger;
[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe![2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.
If you're writing a library and would like to include support for log4js, without introducing a dependency headache for your users, take a look at log4js-api.
There's also an example application.
Contributions welcome, but take a look at the rules first.
The original log4js 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.