How to log into the database when each Job has been dispatched in laravel?

1k Views Asked by At

In my application I need to log when each job is dispatched, retried and executed. The reason why I need this log is to detect whether on a failure the job is re-dispatched or not.

Also I need to keep 1 month long the job dispatch.

In another words I need to log:

  • Time dispatched,
  • Time redispatched,
  • Time finished
  • error that caused re-dispatch
  • where the job has been redispatched.

Is there some sort of trigger in laravel 5.7 that allows you to do custom logs during job dispatch?

So far I have seen that there are the jobs and failed_jobs tables that contains only ephemeral information only during the job execution. After job excecution records are removed.

1

There are 1 best solutions below

2
On

If you want to build it yourself, then Job events

If you want to have a dashboard and logs for everything you mentioned, then Laravel Horizon