Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using nodejs's Forever to output console.logs to screen

Tags:

I just discovered that my nodejs app keeps crashing, so I've used forever app.js to start my app and have it automatically restarted when it crashes.

Problem: Now my app outputs alot of useful information as it runs via console.log and util.log. I used to use screen to run the node app, but now that I'm using forever to run the nodejs app, I can no longer see all the outputs.

Is there any way to see all the output from the nodejs app in realtime?

like image 948
Nyxynyx Avatar asked Apr 29 '12 01:04

Nyxynyx


People also ask

How do I get forever logs?

Forever, by default, will put logs into a random file in ~/. forever/ folder. You should run forever list to see the running processes and their corresponding log file.

How do you check the output of a console log?

Steps to Open the Console Log in Google Chrome By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements". Now you can see the Console and any output that has been written to the Console log.

Can you console log from node modules?

log and console.The built-in console module in Node. js lets you write log messages to standard output (stdout) and standard error (stderr)using the log and error functions, respectively.

Do console logs take up memory?

So, yes for every console. log call, some variables are created. The memory increase depends what and how many times your code logs.


2 Answers

Directly with forever command :

forever logs app.js -f

It shows in realtime output of your application and forever logs (shows detected changes & restart messages).

like image 51
arnaud del. Avatar answered Sep 21 '22 17:09

arnaud del.


You can watch a logfile live by using this shell-command.

 tail -f /path/to/logfile

Not sure if this is what you needed.

like image 34
Zombaya Avatar answered Sep 22 '22 17:09

Zombaya