Gathering detailed insights and metrics for log4js
Gathering detailed insights and metrics for log4js
Gathering detailed insights and metrics for log4js
Gathering detailed insights and metrics for log4js
@log4js-node/log4js-api
For libraries that want to include log4js for logging, but don't want to introduce version conflicts for users that also use log4js. Delegates to whatever log4js version can be found, but does not introduce a specific log4js version.
log4js-extend
log4js + line number
log4js-qradar-syslog-appender
Node.js Log4js syslog appender for QRadar
@log4js-node/logstash-http
Logstash HTTP Appender for log4js-node
npm install log4js
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5,806 Stars
2,219 Commits
770 Forks
112 Watching
15 Branches
155 Contributors
Updated on 26 Nov 2024
Minified
Minified + Gzipped
JavaScript (98.3%)
TypeScript (1.65%)
Shell (0.04%)
Cumulative downloads
Total Downloads
Last day
-1.9%
981,968
Compared to previous day
Last week
3.2%
5,208,691
Compared to previous week
Last month
13%
21,327,588
Compared to previous month
Last year
15.2%
206,641,865
Compared to previous year
5
This is a conversion of the log4js framework to work with node. I started out just stripping out the browser-specific code and tidying up some of the javascript to work better in node. It grew from there. Although it's got a similar name to the Java library log4j, thinking that it will behave the same way will only bring you sorrow and confusion.
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:
Optional appenders are available:
Having problems? Jump on the slack channel, or create an issue. If you want to help out with the development, the slack channel is a good place to go as well.
1npm install log4js
Minimalist version:
1var log4js = require("log4js"); 2var logger = log4js.getLogger(); 3logger.level = "debug"; 4logger.debug("Some debug messages");
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:
1[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 examples/fromreadme.js
):
1const log4js = require("log4js"); 2log4js.configure({ 3 appenders: { cheese: { type: "file", filename: "cheese.log" } }, 4 categories: { default: { appenders: ["cheese"], level: "error" } }, 5}); 6 7const logger = log4js.getLogger("cheese"); 8logger.trace("Entering cheese testing"); 9logger.debug("Got cheese."); 10logger.info("Cheese is Comté."); 11logger.warn("Cheese is quite smelly."); 12logger.error("Cheese is too ripe!"); 13logger.fatal("Cheese was breeding ground for listeria.");
Output (in cheese.log
):
1[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe! 2[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.
Available here.
There's also an example application.
1import * as log4js from "log4js"; 2log4js.configure({ 3 appenders: { cheese: { type: "file", filename: "cheese.log" } }, 4 categories: { default: { appenders: ["cheese"], level: "error" } }, 5}); 6 7const logger = log4js.getLogger(); 8logger.level = "debug"; 9logger.debug("Some debug messages");
We're always looking for people to help out. Jump on slack and discuss what you want to do. Also, take a look at the rules before submitting a pull request.
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.
The latest stable version of the package.
Stable Version
1
5.5/10
Summary
Incorrect Default Permissions in log4js
Affected Versions
< 6.4.0
Patched Versions
6.4.0
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 5/11 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More