Created
April 27, 2019 04:40
-
-
Save Faks/66dad968db9abae1ba6da2ab7621ad34 to your computer and use it in GitHub Desktop.
Split your Laravel daily logs by year/month folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ./config/logging.php | |
return [ | |
/* | |
|-------------------------------------------------------------------------- | |
| Split your daily logs by year/month folders | |
|-------------------------------------------------------------------------- | |
| | |
| ./storage/logs/ | |
| | |
| ├── 2018 | |
| │ └── 12 | |
| │ ├── laravel-2018-12-30.log | |
| │ └── laravel-2018-12-31.log | |
| └── 2019 | |
| ├── 01 | |
| │ ├── laravel-2019-01-01.log | |
| │ ├── laravel-2019-01-02.log | |
| | |
| ..... | |
| | |
| │ ├── laravel-2019-01-30.log | |
| │ └── laravel-2019-01-31.log | |
| └── 02 | |
| ├── laravel-2019-02-01.log | |
| └── laravel-2019-02-02.log | |
| | |
| | |
*/ | |
'default' => env('LOG_CHANNEL', 'stack'), | |
'channels' => [ | |
'stack' => [ | |
'driver' => 'stack', | |
'channels' => ['daily'], // set 'daily' channel | |
], | |
'daily' => [ | |
'driver' => 'daily', | |
'path' => storage_path('logs/' . date('Y/m/') . 'laravel.log'), // add dynamic folder structure | |
'level' => 'debug', | |
'days' => 31, // set the maximum number of days in a month | |
], | |
], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This won't work if you cache config files.
I have another custom implementation here
https://gist.github.com/arun07as/30a3983cf03d0e40afac450a842ad4f7
That extends monologs RotatingFileHandler to generate custom file paths