You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
log4js-node/example.js

23 lines
813 B

var log4js = require('./lib/log4js');
//log the cheese logger messages to a file, and the console ones as well.
log4js.addAppender(log4js.fileAppender('cheese.log'), 'cheese', 'console');
15 years ago
var logger = log4js.getLogger('cheese');
//only errors and above get logged.
15 years ago
logger.setLevel('ERROR');
//console logging methds have been replaced with log4js ones.
console.error("AAArgh! Something went wrong", { some: "otherObject", useful_for: "debug purposes" });
//these will not appear (logging level beneath error)
15 years ago
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');
15 years ago
logger.warn('Cheese is quite smelly.');
//these end up on the console and in cheese.log
logger.error('Cheese %s is too ripe!', "gouda");
15 years ago
logger.fatal('Cheese was breeding ground for listeria.');