Thursday 15 August 2013

node.js - winston http transport example -



node.js - winston http transport example -

i need working illustration post logs on server using http transport. i'm able utilize file transport , console transport log message in file , on console. same way tried doing http transport also, source cod winston clien looks :

var winston = require('winston'); var logger = new (winston.logger)({ transports: [ new (winston.transports.console)(), new (winston.transports.http)({ host: 'localhost', port:8080 }) ] }); logger.log('info', 'hello world');

while runnign code error :

d:\balwant\devlopment-env\loggingdemo\node_modules\winston\lib\winston\transports\http.js:52 req = (self.ssl ? https : http).request({ ^ referenceerror: self not defined @ http._request (d:\balwant\devlopment- env\loggingdemo\node_modules\winston\lib\winston\transports\http.js:52:10) @ http.log (d:\balwant\devlopment-env\loggingdemo\node_modules\winston\lib\winston\transports\http.js:109:8) @ emit (d:\balwant\devlopment-env\loggingdemo\node_modules\winston\lib\winston\logger.js:175:17) @ d:\balwant\devlopment-env\loggingdemo\node_modules\winston\node_modules\async\lib\async.js:111:13 @ array.foreach (native) @ _each (d:\balwant\devlopment-env\loggingdemo\node_modules\winston\node_modules\async\lib\async.js:32:24) @ object.async.each (d:\balwant\devlopment-env\loggingdemo\node_modules\winston\node_modules\async\lib\async.js:110:9) @ logger.log (d:\balwant\devlopment-env\loggingdemo\node_modules\winston\lib\winston\logger.js:203:9) @ object.<anonymous> (d:\balwant\devlopment-env\loggingdemo\logger.js:10:8) @ module._compile (module.js:456:26)

since i'm new node.js, i've no thought how deal it. tried googling solution not any. plese help me.

thanks

first winston , winstond different packages. can check this blog post difference.

you might need whip-up own http transport winston (if want utilize winston). can work specific endpoint protocol.

you can create custom winston transport specified here. can utilize request send log info http endpoint.

good luck.

web transport

i don't believe winston.transports.http exists think you're looking this:

new winston.transports.webhook({ 'host': 'localhost', 'port': 8080, 'path': '/collectdata' })

as shown in this example.

winstond

my mistake, it have winston.transports.http you'll need winstond.

you can check this example utilize winstond http daemon. send http logs it.

so this:

new winston.transports.http({ host: 'localhost', port: 8080})

should pointing winstond daemon like:

var winstond = require('winstond'); var http = winstond.http.createserver({ services: ['collect', 'query', 'stream'], port: 8080 }); http.add(winstond.transports.console, {}); http.listen();

node.js winston

No comments:

Post a Comment