0

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.

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

2
  • what have you already tried? Commented Apr 26, 2015 at 6:23
  • I tried with puuting the if condition in the whole code to check for commandline argument, if it is not present then log to the console. Commented Apr 26, 2015 at 6:28

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the quick response, I should have done more thorough search.
Also you can search on npm any other apreciated modules: npmjs.com/search?q=log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.