Reputation: 33368
My CakePHP 3.x app is running on Heroku. When in production mode (debug => false
) none of the errors show up in the Heroku logs. I suspect that CakePHP is trying to write them to it's own logs/error.log
but I don't think there's a way to access that in the Heroku environment. I think I need to configure CakePHP to send errors to STDOUT... then Heroku will "see" them. How do I do that in CakePHP v3.x?
Here's the relevant section of my config file:
'Error' => [
'errorLevel' => E_ALL & ~E_DEPRECATED,
'exceptionRenderer' => 'Cake\Error\ExceptionRenderer',
'skipLog' => [],
'log' => true,
'trace' => true,
],
This question is exactly the same as mine, but for CakePHP 2.x.
This Heroku documentation is also for CakePHP 2.x.
Here is the CakePHP documentation on logging which is vague on this matter.
I tried adding...
use Cake\Log\Log;
Log::config('default', [
'engine' => 'Syslog'
]);
...to my config file but it didn't work.
Upvotes: 3
Views: 954
Reputation: 682
Here's where we ended up:
# Configure all logs for Heroku.
foreach (array_keys(Configure::read('Log')) as $log) {
Configure::write("Log.$log.className", 'Console');
}
This applies the solution from emersonthis to every configured log. We place this in our configuration override files for Heroku environments. I'm not sure about the engine
vs. className
difference between our examples. The current CakePHP 3 cookbook uses className for its own examples.
Upvotes: 1
Reputation: 33368
This is a placeholder answer (while the info is still fresh) in my mind until NDM submits one...
To log errors to the console, add...
Log::config('default', [
'engine' => 'Console'
]);
...to bootstrap.php
This results in PHP errors showing up when you run heroku logs
. The mistake I made was trusting the Heroku addon Logentries, which is a GUI tool for viewing logs. Even with the above in place, Logentries still isn't showing any PHP errors, but that's a different issue.
Possibly relevant:
At the bottom of the Heroku docs it shows you how to connect applications that log to their own files (like CakePHP) with Heroku's black magic output... it didn't work for me, but your milage may vary.
Upvotes: 0