1

I'm looking into some issues I'm having with my Heroku Review Apps.

It appears that from Bash, there's no way to access the config (environment variables) or logging. If I run:

heroku logs --tail

This just comes back with logs from the production app (which makes sense, since there doesn't seem to be a way to keep the scope at the review app). I can see the Review App logs from within the Heroku dashboard, but even this seems a bit off, as subsequent refreshes will omit different lines from the log (which is why I'm trying to just see them from Bash).

Also, if I do:

heroku config

It returns back the expected config values (i.e. DATABASE_URL), but again, I'm not sure if this is just for production.

For example, running this from the review app:

console.log("process.env.PORT: " + process.env.PORT);
console.log("process.env.DATABASE_URL: " + process.env.DATABASE_URL);
console.log("process.env.PAPERTRAIL_API_TOKEN: " + process.env.PAPERTRAIL_API_TOKEN);

The PORT is returning a value, but both DATABASE_URL AND PAPERTRAIL_API_TOKEN are coming back undefined, even though these are both populated in heroku config.

So my questions are:

1) How do I view a Review App's logs from Bash (or any other reliable method other than the Heroku dashboard)?

2) Are the config values different between Review Apps and production, and if so, how do I configure them for Review Apps?

Jerad Rose
  • 15,235
  • 18
  • 82
  • 153

3 Answers3

1

Use --app to point to your review app, e.g:

heroku config --app my_review_app
heroku config:set VAR=VALUE --app my_review_app
Yoni Rabinovitch
  • 5,171
  • 1
  • 23
  • 34
1

Yoni is exactly right, but here are more details.

When running heroku config, the first line of the response shows the app it is currently pointing to. This should've been my first clue, and I missed it initially.

$ heroku config
=== fathomless-meadow-38193 Config Vars
DATABASE_URL: postgres://xxxxxxxxxx...

Once I ran the config for my review app, it indeed returned empty.

$ heroku config --app blooming-river-14132-pr-2
=== blooming-river-14132-pr-2 Config Vars

As Yoni said, you can use the -app switch to specify an app when setting config variables. But I wanted my default app to point to my blooming-river app, which lead me to this post on how to change this:

$ heroku git:remote -a blooming-river-14132-pr-2

Now I can set DATABASE_URL using:

$ heroku config:set DATABASE_URL=POSTGRES://xxxxxxxx...

I don't really like having to manually set it for each new pull request, so I found out that Review Apps can inherit config vars from a parent app. Unfortunately, I never could get this work, at least not for DATABASE_URL.

So I'm still trying to figure that out, and will update this answer if I do.

Community
  • 1
  • 1
Jerad Rose
  • 15,235
  • 18
  • 82
  • 153
0

There are addons to collect the logs and have so many other features like alerts.

So you can consider using one of them. I am just giving one that actually we are using in our app called Logentries

https://elements.heroku.com/addons/logentries

Naga Srinu Kapusetti
  • 1,563
  • 15
  • 12