the plugin of the light-api server for log service
npm install light-api-log4jjavascript
let logconf = require(./${env}/log.json);
... ...
"plugins":{
"light-api-log4j":logconf
}
`
2. 配置 /log.json
`json
{
"appenders": {
"sysMsg": { "type": "stdout" },
"app": { "type": "file", "filename": "data.log" }
},
"categories": {
"default": { "appenders": [ "sysMsg", "app" ], "level": "debug" }
}
`
3.使用
`javascript
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 ...');
... ...
}
``