add the bunyan logger to the loopback application.
npm install loopback-component-logThe loopback component add the log function to the loopback.
1. Install in you loopback project:
npm install --save loopback-component-log
2. Create a component-config.json file in your server folder (if you don't already have one)
3. Configure options inside component-config.json:
``json`
{
"loopback-component-log": {
"enabled": true,
"name": "logger",
"http": true,
"level": "info",
"useStdOut": true,
"useLogFile": false,
"path": "./logs"
"maxResponseTime": 30000,
"excludes": ["req","res"]
...
}
}
enabled
- [Boolean]: whether enable this component. defaults: truehttp
- [Boolean]: whether log the http request. defaults: truelevel
* the Model.json can control it if not settings.
- [String]: the log level string: "trace", "debug", "info", "warn", error", "fatal". defaults: "info"useStdOut
- [Boolean]: whether log to stdout. defaults: trueuseLogFile
- [Boolean]: whether log to the file. defaults: falsepath
- [String]: the log folder. defaults: ./logsperiod
- [String]: the log file period. defaults: 1dlogType
- [String]: the log file type. defaults: rotating-filemaxLogs
- [Integer]: the max count of the log files. default :10maxResponseTime
- [Integer]: treat if as fatal if response exceed the time. default :30000
* 0 or null means do not enable this feature .
- see the
- express-bunyan-logger
Just enable it on component-config.json.
`js
var loopback = require('loopback');
var rootlog = loopback.log;
rootlog.info("hi");
rootlog.warn({lang: 'fr'}, 'au revoir');
`
set DEBUG=loopback:component:log` env vaiable to show debug info.
+ !syslog stream