节点js中的日志文件重定向

[英]log file redirection in node js


I am writing a socket server in nodejs using websocket library, I have a requirement where if I give a logfilename in the server.js as a argument then all the logs should be redirected to logfile otherwise it should be displayed on the console.

我正在使用websocket库在nodejs中编写套接字服务器,我有一个要求,如果我在server.js中给出一个logfilename作为参数,那么所有日志都应该重定向到logfile,否则它应该显示在控制台上。

It seems to be very trivial issue but I am very new to node js, can you guys help me how to acheive it.

这似乎是一个非常微不足道的问题,但我对节点js很新,你能帮助我如何实现它。

1 个解决方案

#1


3  

You can try using this library. It has a file transport logger. https://github.com/winstonjs/winston

您可以尝试使用此库。它有一个文件传输记录器。 https://github.com/winstonjs/winston

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2015/04/26/72071124b60286686b29fb83de40ee69.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告