//使用
- 引入框架
let logconf = require(`./${env}/log.json`);
... ...
"plugins":{
"light-api-log4j":logconf
}
- 配置 /log.json
{
"appenders": {
"sysMsg": { "type": "stdout" },
"app": { "type": "file", "filename": "data.log" }
},
"categories": {
"default": { "appenders": [ "sysMsg", "app" ], "level": "debug" }
}
3.使用
handler: function (request, reply) {
let logger = this.getLogger(__filename,category);
logger.trace('LIGHT trace ...');
logger.debug('LIGHT debug ...');
logger.info('LIGHT info ...');
logger.warn('LIGHT warn ...');
logger.error('LIGHT error ...');
logger.fatal('LIGHT fatal ...');
... ...
}