Log4js - The Logging Framework for JavaScript with no runtime dependencies | Since 2005
js/log4js.min.js
to your project.Add the JavaScript file to head of HTML page:
<head>
<script src="https://github.com/stritti/log4js/raw/master/log4js.min.js" type="text/javascript"></script>
</head>
Add script for instantiation of Logger:
let consoleLog = new Log4js.Logger("consoleTest");
consoleLog.setLevel(Log4js.Level.ALL);
let consoleAppender = new Log4js.ConsoleAppender(true);
consoleLog.addAppender(consoleAppender);
consoleLog.trace('I was traced!')
Within sources there is a more detailed example.
The project is seperated in modules. Core JavaScript module is located in subdirectory log4js
├───log4js: Main JavaScript Log4js module
├───log4js-servlet: Java Servlet to collect AJAX-Logs serverside
├───log4js-solr: configuration to collect logs using Apache SOLR
├───log4js-site: (outdated) project documentation
Main JavaScript module
To build the JavaScript library we use npm and grunt.
cd log4js
npm install
grunt build
Include then the target/log4js.min.js
file in your project.
More details in the Wiki
The servlet is Java based project which is compiled using maven
.
For more details see README.md in the subdirectory log4js-solr
Outdated documentation.
Pull Requests are very welcome.
There are a lot other projects which are started logging in JavaScript:
There is a very active fork of current log4js framework modified for node.js usage: https://github.com/nomiddlename/log4js-node
Further loggers could be found (and added!) in the Wiki.