Log4js 2.9.0 日志管理插件
Node端的日志插件Log4js,以后版本更新了继续跟进
https://github.com/log4js-nod...
安装&&版本
npm install log4js 或者 yarn add log4js
"express": "4.16.2", "log4js": "2.9.0",
最简单的写法
var log4js = require('log4js'); var logger = log4js.getLogger(); logger.level = 'debug'; logger.debug("Some debug messages");
稍微具体一些
const log4js = require('log4js'); log4js.configure({ appenders: { cheese: { type: 'file', filename: 'cheese.log' } }, categories: { default: { appenders: ['cheese'], level: 'error' } } }); const logger = log4js.getLogger('cheese'); logger.trace('Entering cheese testing'); logger.debug('Got cheese.'); logger.info('Cheese is Gouda.'); logger.warn('Cheese is quite smelly.'); logger.error('Cheese is too ripe!'); logger.fatal('Cheese was breeding ground for listeria.');
输出结果
[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.参考文献
https://github.com/log4js-nod...
相关推荐
丨Fanny丨Cri 2020-04-20
AndyXuq 2019-08-20
MrLiar 2015-11-09
lert0 2019-07-01
mmayanshuo 2019-07-01
networkhunter 2019-06-30
80447704 2019-06-29
ZMC 2019-06-28
networkhunter 2019-06-28
New丶Elements 2019-06-27
87510194 2019-06-26
ZMC 2019-06-26
networkhunter 2019-05-31
mmayanshuo 2019-06-26
ZMC 2019-06-25
mygirlgod 2019-06-21
SailingAptech 2019-06-20