Command line output when running application as Windows service

In a Windows 2008 R2 environment, I have a socket.io chat application that I'm currently starting from command line:

node app.js

This outputs different information about the app's state on the screen, which I can of course see in the command line window.

I would like to run the node app as a Windows service and I found out that NSSM will help me do that, which is great. But I would like to also be able to look at the output, when needed.

Is there any way to get that output and put it in a log file(similar to IIS/Apache logs)?

Thanks

https://github.com/nomiddlename/log4js-node allows you to save your logs in many output type, file is one of them.

It's possible to use it to replace the console output in your new output of your choice.

var log4js = require('log4js');

log4js.loadAppender('file');
log4js.addAppender(log4js.appenders.file('output.log'));

// the important part ;)
log4js.replaceConsole()
//

var logger = log4js.getLogger();
logger.debug("Debug message");

console.log('debug from the console');