Search code examples
laravelamazon-cloudwatchlaravel-vapor

Why do logs that are run by schedule:run on Laravel Vapor not saving in Cloudwatch?


So I have this in my Kernel.php $schedule->command('command:name')->hourly()->withoutOverlapping(); but it never stores the logs in Cloudwatch. However, if I run it manually using vapor command staging --command="php artisan command:name", they do get stored in Cloudwatch.

I am assuming it has to do with cron based commands in Laravel Vapor storing their output to /dev/null but I might be wrong. My goal is to capture these logs, any help? To add further, my command basically fetches data from an API for 50 records.


Solution

  • This is from the official Laravel Vapor documentation:

    Log Messages

    Due to Vapor limitations, log messages from scheduled tasks will not appear in AWS CloudWatch or Vapor UI. As a workaround, you should dispatch a queued job from your scheduled tasks and write log messages from your queued job.

    When you execute vapor command staging --command="php artisan command:name you are using the CLI. This mode generates logs and that's the reason you can see them.