Skip to content
Advertisement

Laravel storage returns FileNotFoundException But file exists

I want read file content in laravel 6, the file already exists but laravel return not found exception.

This is my logs files directory: /var/www/html/myLaravelLab/storage/logs/laravel-2019-10-14.log

$contents = Storage::get(storage_path('logs/laravel-2019-10-14.log'));

Laravel return this error: IlluminateContractsFilesystemFileNotFoundException

But file already exists!

I want read file contents.


Laravel Version: 6.2.0 – PHP Version: 7.2.19

Advertisement

Answer

In config/filesystems.php add new disk logs:

'disks' => [
        'logs' => [
            'driver' => 'local',
            'root' => storage_path('logs'),
        ],
// orher disks...

Now you can get log files:

Storage::disk('logs')->get('laravel-2019-10-14.log');
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement