solid_queue icon indicating copy to clipboard operation
solid_queue copied to clipboard

Specify logger for recurring task

Open Benoit-Baumann opened this issue 7 months ago • 1 comments

Hi @rosa,

Thanks for the awesome work !

We are currently using the whenever gem to manage recurring rake tasks and are considering using SolidQueue's recurring tasks to replace this gem. One thing we love about whenever is the ability to specify a logger per cron job (cf https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs).

It would be nice to have something similar in SolidQueue, for example :

production:
  a_periodic_job:
    class: MyJob
    args: [ 42, { status: "custom_status" } ]
    schedule: every second
    logger:  "log/a_periodic_job.log"
  a_cleanup_task:
    command: "DeletedStuff.clear_all"
    schedule: every day at 9am
    logger:  "log/a_cleanup_task.log"
  another_task:
    command: "DoStuff.perform"
    schedule: every day at 9am

If no logger is specify, SolidQueue's default logger is used.

What do you think about it ?

Benoit-Baumann avatar Apr 16 '25 09:04 Benoit-Baumann

Hey @Benoit-Baumann, thanks for your kind words! Ahhh, whenever is super cool! That's a great feature. If I understand this correctly, the logger that you'd want to override would be this one? I wonder if, in that case, it'd be easy just to make that thread-safe so that you could specify different loggers per job. Solid Queue's logger is used for Solid Queue's own work, rather than the job it's running, that'd be Active Job's logger 🤔

rosa avatar Apr 16 '25 09:04 rosa