Skip to main content
Tutorial Free

Laravel log - single file or files by date?

July 04, 2016
2 min read

Tutorial last revisioned on October 07, 2022 with Laravel 9

Laravel logging mechanism is pretty simple - it writes all the errors to a file at /storage/logs/laravel.log. It's convenient until the file gets bigger. And then you have a problem to find a bug from yesterday or some days ago. How can you solve this? Basically, the real problem looks like this: you SSH to your server, go to /storage/logs folder and run ls -l command for the files list with information. And see this:
-rw-rw-r-- 1 forge forge 31580639 Jul  4 07:52 laravel.log
True story from one of my projects - laravel.log file is 31 MB. It's pretty difficult to find anything there, if a client reports that "unknown bug" happened to him a few days ago. Luckily, it's really easy to change - it's only one setting in config/logging.php file:
    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single'],
            'ignore_exceptions' => false,
        ],
As you can see, by default the channel is single file, but you can change it to daily (or others, leaving that for you to explore).

When you change the setting to daily, instead of one laravel.log - you will get separate file for each date - something like laravel-2022-10-07.log.

Read more in the official documentation.

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Recent Courses

Laravel Modules and DDD

16 lessons
1 h 59 min

How to Build Laravel 12 API From Scratch

28 lessons
1 h 21 min

Laravel HTTP Client and 3rd-Party APIs

7 lessons
50 min

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.