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?
I guess this works (not tried):
Log::useFiles('php://stderr');
What's the place to put this?
Well, since Laravel is flexible you can put anywhere you want. Maybe in your AppServiceProvider register function.
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.
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.
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).
Please sign in or create an account to participate in this conversation.