4

So I am putting my app on a server and I want to see some console logs generated from my nodejs app. Before putting it on the server I saw the output of my console log on my terminal, but where do I find the output for these on Ubuntu? I'm running version 16.04 on Ubuntu

Ricky
  • 717
  • 3
  • 10
  • 21
  • What language is the app written in? Do you have a code snippet / example? How are you deploying your application? In a VM, Docker, as a standalone process? –  Feb 06 '18 at 22:04
  • You see I am so new to this I am not sure how to answer you about how I am deploying this. I ssh'ed on a server on rackspace set up my app with git clone set up reverse proxy with nginx and installed mongo – Ricky Feb 06 '18 at 22:32
  • Here is a example snippet let convert = () => { console.log('Now converting'); cmd.run(command)} console.log(command) – Ricky Feb 06 '18 at 22:33
  • So this is Node.js –  Feb 06 '18 at 23:00
  • Yes changes have been made to the question to reflect this – Ricky Feb 06 '18 at 23:03

3 Answers3

4

Lifted straight from @SlovyanskiyYehor comment two years ago, but I missed his answer as a comment. Also answered here: Make pm2 log to console.

If you are using pm2 to start your node.js application, you can use:

pm2 logs

or for just a single app running in pm2:

pm2 logs yourAppNameHere
Adam Marsh
  • 976
  • 11
  • 21
0

If you are using some bash script which is runed by cron for example, you can specify file where you need to output all logs of your app It will looks like that:

myApp > /path/to/logs/myAppLogs.txt

This command will run application myApp and put all logs into "/path/to/logs/myAppLogs.txt"

Also you can put this string into cron directly without some bash scripts

Of course you can see all console logs by user here ~/.bash_history but it`s not always useful

  • Is there no way to make it so when I console log something it just shows on the terminal? – Ricky Feb 06 '18 at 22:55
  • What you use to start your app on the server? If you are using pm2 to start your node.js application, you can use next command: **pm2 logs** to view logs – SlovyanskiyYehor Feb 06 '18 at 23:10
  • @ SlovyanskiyYehor say that as an answer so I can accept your answer, that is exactly what I was looking for – Ricky Feb 06 '18 at 23:13
0

If you used pm2, you can check log in this folder:

/root/.pm2/log
MrXo
  • 131
  • 1
  • 9