Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show all console.log from node.js in heroku?

I have deployed a node.js application to node.js but not able to see the complete console.log statements from my app. I am using:

heroku logs

Some of the logging is shown but looks like it is not the complete logs. Is there a node.js package to send emails from the deployed app? Email works fine from my localmachine btw.

Email code:

console.log('try to send email hold on');
    var nodemailer = require("nodemailer");
    var smtpTransport = nodemailer.createTransport({
        service: "Gmail",
        auth: {
            user: "[email protected]",
            pass: "mypw"
        }
    });

    smtpTransport.sendMail({
        from: "Dikkebil", // sender address
        to: "[email protected]", // comma separated list of receivers
        subject: "Error body", // Subject line
        text: 'Error body: ' +error.body+ '\n'+ 'error type:' + error.type +'\n' +'error statuscode:' +error.statusCode +'\n'  + 'error args:' + error.arguments[0]
    }, function(error, response){
        if(error){
            console.log(error);
        }else{
            console.log("Message sent: " + response.message);
        }
    });
like image 216
Pindakaas Avatar asked Jun 21 '15 10:06

Pindakaas


People also ask

How do I see Heroku console logs?

You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain. You can't view logs for apps in Shield spaces with Private Space Logging enabled. Retrieve logs from your log drain instead.

How do I see Heroku output?

This output is available via the Heroku Dashboard. You can get to this from the drop down on the Review app card in the Pipeline page, from that dropdown choose the "View initial app setup" option.

Can I console log from node module?

You can put console logs but just remember to restart the server. Hot reload does not detect changes in dist folders of libraries in node_modules.


Video Answer


3 Answers

From the heroku doc:

The logs command retrieves 100 log lines by default. You can specify the number of log lines to retrieve (up to a maximum of 1,500 lines) by using the --num (or -n) option.

$ heroku logs -n 200

So probably you need to request more lines with -noption.

As per comment received, you can also stream the current log with:

$ heroku logs --tail

Please look at the doc

like image 177
michelem Avatar answered Oct 19 '22 10:10

michelem


I always use heroku logs -t --app your-app-name It keeps the heroku console open .

like image 43
Sebastian Salamanca Avatar answered Oct 19 '22 11:10

Sebastian Salamanca


I use:

heroku logs -n 1000 --tail

that 1000 is the number of lines you want to see and can be up to 1500.

like image 36
ILoveReactAndNode Avatar answered Oct 19 '22 11:10

ILoveReactAndNode