Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Vincent's avatar

Logging on to STDOUT

Hello!

I'm running Laravel 5 on Heroku. How can I setup Laravel to send all log messages to STDOUT or STDERR?

0 likes
6 replies
fuhrmanns@gmail.com's avatar

Well, since Laravel is flexible you can put anywhere you want. Maybe in your AppServiceProvider register function.

Stephen's avatar

In config/app.php change the logging option to this:

'log' => 'errorlog',

That tells Monolog to send logged events to STDERR. Heroku will then be able to capture Laravel's logged items.

4 likes
jbitfm's avatar

Stumbled across this old thread...however it helped me to find the path to the solution.

My specific problem was that my Laravel 6.3 app didn't produce any log output on Heroku, which is configured to send all logs to Papertrail.

So as of now, Nov 2019, the right way is to set an environment variable in .env:

LOG_CHANNEL=stderr

This way, I'm now sending all logs from Heroku PHP Laravel application to Papertrail.

WouterFlorijn's avatar

To add to this, you can also copy the stderr item in config/logging.php and replace php://stderr by php://stdout. To log to stdout instead of stderr (which is more logical unless you're only logging exceptions).

2 likes

Please or to participate in this conversation.