Setting a dynamic log path when using Laravel queues

I had a need to change the log path for a job when using Laravel queues. I created a pipeline for file processing and wanted to have the log file name as the name of the file. This would allow my to easily check to see how the file processed. As you know when using queues, they are a long running process so it’s a little difficult to change the log file path because just changing the config will not work. After digging into Laravel log I found I could update the underlying Monolog stream handler.

$handler = new StreamHandler($path);

$handler->setFormatter(new LineFormatter(null, "Y-m-d H:i:s", true, true));



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s