gpt4 book ai didi

node.js - 如何在heroku中显示node.js中的所有console.log?

转载 作者:IT老高 更新时间:2023-10-28 21:56:23 28 4
gpt4 key购买 nike

我已将 node.js 应用程序部署到 node.js,但无法从我的应用程序中看到完整的 console.log 语句。我正在使用:

heroku logs

显示了一些日志记录,但看起来不是完整的日志。是否有 node.js 包可以从部署的应用程序发送电子邮件?顺便说一句,电子邮件在我的本地机器上工作正常。

电子邮件代码:

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

smtpTransport.sendMail({
from: "Dikkebil", // sender address
to: "myemail@gmail.com", // 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);
}
});

最佳答案

来自 heroku 文档:

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

所以您可能需要使用 -n 选项请求更多行。

根据收到的评论,您还可以通过以下方式流式传输当前日志:

$ heroku logs --tail

look at the doc

关于node.js - 如何在heroku中显示node.js中的所有console.log?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30963399/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com