節點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


注意!

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



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