Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amitsolanki24_'s avatar

Hoe can i create log file on week basis instead of daily in laravel

Hello everyone, I'm new here I want to create log file on week basis

0 likes
4 replies
dhanar98's avatar
dhanar98
Best Answer
Level 1

@amitsolanki24_ Update the config/logging.php

'channels' => [
    // Other log channels...

    'weekly' => [
        'driver' => 'single',
        'path' => storage_path('logs/laravel-' . now()->format('Y-W') . '.log'),
        'level' => 'debug',
        'days' => 7,
    ],
],

change .env file

LOG_CHANNEL=weekly

update the config/logging.php code in the default option

'default' => env('LOG_CHANNEL', 'weekly'),

Hope this works for you.

1 like
amitsolanki24_'s avatar

@dhanar98 thanks for your response. I have doubt why you use 'days' => 7 and if i change it to 10 or i will remove it, so what will happen ?

1 like
dhanar98's avatar

@amitsolanki24_ the days 7 is default - there is no effect if you are using weekly format otherwise if your using the driver in daily format that time the last 7 days log files will be keep in the system. so in your weekly format you need to remove the log files manually or run the task.

1 like

Please or to participate in this conversation.