Convenience module wrapping log4js-node library and logFaces remote appenders for client and server side JS applications
- those who need proper logging mechanism integrated into js apps
- those who use (want/can use) log4js-node as logging framework
- those who use (want/can use) logFaces as a centralized remote log management
- single code base, it will run in both node.js and most modern browsers
- offers simple integration wrapper to quickly setup remote logging on application side
- provides simple controlling functions like setting thresholds, context, remote url.
// this is what you would normally do in client js applications
// setup HTTP based remote logging with logFaces web receiver
var LogManager = require('./LogManager');
var log = LogManager.getLogger("app");
LogManager.setThreshold("INFO");
LogManager.setupRemote({
application: "my-app-name",
url: "http://myhost:8050/receivers/myapp"
});
log.warn("this comes from the browser based app");
// turn logging off
LogManager.setThreshold("OFF");
// setup UDP remote logging with logFaces UDP receiver
var LogManager = require('./LogManager');
var log = LogManager.getLogger("app");
LogManager.setThreshold("TRACE");
LogManager.setupRemote({
application: "my-nodejs-app",
remoteHost: "my-server-host",
port: "55201"
});
log.info("this comes from node.js server app");
// set MDC context, this will result in all logs sent out to server
// with certain diagnistic context like 'user' and 'job'
LogManager.setContext("user", "foo");
LogManager.setContext("job", "bar");
log.info("this will arive to server with context variables");