Boaz Saragossi Boaz Saragossi - 3 years ago 145
PHP Question

How can i see my echo prints on the heroku logs?

I have a free PHP heroku webapp that is running fine.
(sending push notifications).

When i print from within the PHP app like that:

echo 'sending push !!!' . PHP_EOL;

I don't see these prints on the heroku logs when i do

heroku --tail

any idea why ?

Answer Source

You simply write to stderr:

file_put_contents("php://stderr", "sending push !!!".PHP_EOL);

Or, if you're using Monolog:

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('yourlogger');
$log->pushHandler(new StreamHandler('php://stderr', Logger::DEBUG));

$log->addNotice('sending push !!!');

Don't use a particular log file path, or LOG_PATH, that won't actually do anything.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download