infodev
infodev

Reputation: 5245

printing node output in a file in Linux

I have a large app output , and I should analyse the output.

It's difficult to do it on the terminal so I would print the output into a file to analyse it easier.

So how can I redirect nodejs app.js output into a file in Ubuntu ?

Upvotes: 2

Views: 1101

Answers (1)

Fabian Rivera
Fabian Rivera

Reputation: 1198

You can do it by redirecting your app's output (stdout and stderr) to the desired file:

$ node app.js &> filename.txt

If you do this, everything that you log using console.log() and console.err() will be included in your file.

Of course, it would be better if you programmatically write to a file so you can include only what you want to keep in the file.

Upvotes: 2

Related Questions