node.js - 为什么我的node.js heroku 任务console.log 语句没有显示在heroku 日志中?

标签 node.js heroku

我在heroku中设置了一个 super 简单的node.js任务this blog 。一切似乎都正常,但当我使用 heroku logs --tail 时,我的 console.log 语句不会显示在控制台中。

我的任务如下所示:

#!/usr/bin/env node

var firebase = require('firebase')
console.log('I have loaded firebase');

我知道它正在运行,因为我在 pacakages.json 中没有 firebase npm 包并收到了预期的错误。一旦解决了,一切似乎都运行良好,但我没有从 console.log 行中得到任何输出。 =[

我使用 heroku run reconcileTasks 执行任务,并在日志尾部获得以下输出:

2016-02-25T21:47:00.483677+00:00 heroku[api]: Starting process with command `reconcileTasks` by somecoolfella@geemail.com
2016-02-25T21:47:01.648730+00:00 heroku[run.2829]: Awaiting client
2016-02-25T21:47:01.687472+00:00 heroku[run.2829]: Starting process with command `reconcileTasks`
2016-02-25T21:47:01.945501+00:00 heroku[run.2829]: State changed from starting to up
2016-02-25T21:47:03.964158+00:00 heroku[run.2829]: Process exited with status 0
2016-02-25T21:47:03.991854+00:00 heroku[run.2829]: State changed from up to complete

最佳答案

安排任务过夜运行后,我发现日志显示了我期望的消息。显然,console.log 会转到用户将看到它的上下文。当我通过heroku run命令手动运行它时,它会显示在我正在工作的控制台中,但是当heroku调度程序运行它时,它会显示在日志中。这是一些非常酷的魔法。 =]

2016-02-26T05:30:16.396497+00:00 heroku[api]: Starting process with command `reconcileTasks` by scheduler@addons.heroku.com
2016-02-26T05:30:17.623505+00:00 heroku[scheduler.7098]: Starting process with command `reconcileTasks`
2016-02-26T05:30:18.316360+00:00 heroku[scheduler.7098]: State changed from starting to up
2016-02-26T05:30:19.866568+00:00 app[scheduler.7098]: I have loaded firebase
2016-02-26T05:30:20.819687+00:00 heroku[scheduler.7098]: State changed from up to complete
2016-02-26T05:30:20.805612+00:00 heroku[scheduler.7098]: Process exited with status 0

关于node.js - 为什么我的node.js heroku 任务console.log 语句没有显示在heroku 日志中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35641158/

相关文章:

ruby-on-rails - 使用 Rails 4 错误在 Heroku 上创建 postgres 数据库

javascript - 尽管使用了 Async 模块,为什么这些函数仍然异步执行

node.js - Digital Ocean Dokku 无法选择构建包

node.js - 如何在node.js中使用graphicsmagick裁剪圆形图片(其他使用任何其他方式在node.js上制作此图片)

heroku - 在Heroku上托管Dart应用程序的问题

ruby-on-rails - Heroku 上的 Rails 在启动时崩溃

javascript - 在运行时获取 node.js 版本

javascript - Mongo 聚合游标和计数

Heroku 上的 Node.js 和 Memcache ?

ruby-on-rails - ActionController::RoutingError(没有路由匹配 [GET] "/assets/blah.png") Heroku