Skip to content
Advertisement

Heroku not showing log messages created during scheduled tasks

I’m using Heroku to host a Lumen app. I’ve setup the logging to send messages to stdout:

JavaScript

I’ve tested this works by adding a log message to the schedule function

JavaScript

The Heroku logs show:

JavaScript

However the update:daily command has a number of log messages inside it and none of them are showing up.

I thought this might be because of the > '/dev/null' so I tried adding ->sendOutputTo('php://stdout') and ->sendOutputTo(base_path('storage/logs/cronjobs.log')) to the scheduled task but neither works.

Here’s my Procfile:

JavaScript

Advertisement

Answer

Laravel uses the > '/dev/null' when you do not call ->sendOutputTo(). I couldn’t figure out an appropriate way to use the ->sendOutputTo() function to send to stdout.

What I did to fix this issue was change the ->command() function to a ->call(function(){}) function and executed the same single line of code the terminal command could have called. When laravel calls a Closure, it does not dump the output to > '/dev/null'.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement