restify-log-middleware
This is a small middleware to use with restify to generate log inside req's using bunyan and elasticsearch modules.
First thing
npm install --save restify-log-middleware
Full usage
...var logFactory = ; var options = "elasticSearchConfig": "indexPattern": "[logstash-]YYYY.MM.DD" "type": "logs" "host": "elasticSearchIp:port" "logLevel": 10 "logName": "myLogName" "withstdout" : true; ...//in your routes config...var logMiddleware = logFactory;server;...//or...server;...//or to use with before all routesserver; //it will generate an req.log object. You can use it like this:{ var log = reqlog log = log; log; ... log; ... log; ...}
OPTIONS
You need to use at least:
- logLevel //as number (try 10)
- logName //as string
As optional, you can set up your own elasticSearch configuration like this:
elasticSearchConfig: "indexPattern": "[logstash-]YYYY.MM.DD" "type": "logs" "host": "elasticSearchIp:port"
If you don't need to use process.stdout
, just turn off this option:
"withstdout" : false