rap2hpoutre / laravel-log-viewer

:dromedary_camel: Laravel log viewer
MIT License
3.13k stars 373 forks source link

PHP 8.2, Laravel 9, RecursiveDirectoryIterator::__construct(/var/www/html/storage/logs//var/www/html/storage/logs/eApply): Failed to open directory: No such file or directory #302

Open Delia-SimpleKYC opened 4 months ago

Delia-SimpleKYC commented 4 months ago

Hi, I am getting this error when using a subdirectory inside the logs directory, to save the logs:

This is my config/logging.php configuration: 'eApply' => [ 'driver' => 'daily', 'path' => storage_path('logs/eApply/eApply.log'), 'level' => 'debug', ],

And then, when I open the log viewer, this error appears: RecursiveDirectoryIterator::__construct(/var/www/html/storage/logs//var/www/html/storage/logs/eApply): Failed to open directory: No such file or directory

I'd appreciate your help on this. Thanks in advance

Delia-SimpleKYC commented 4 months ago

@rap2hpoutre any ideas about the above? maybe I have to set something in the config file or something like that?

elminson commented 4 months ago

Hi @Delia-SimpleKYC, Can you try to remove storage_path and logs from the path value?

'eApply' => [
'driver' => 'daily',
'path' => 'eApply/eApply.log',
'level' => 'debug',
],

is my believe path will attach the current log path to the route (/var/www/html/storage/logs//var/www/html/storage/logs/eApply)

as is showing in your error RecursiveDirectoryIterator::__construct(/var/www/html/storage/logs//var/www/html/storage/logs/eApply): Failed to open directory: No such file or directory

Delia-SimpleKYC commented 4 months ago

@elminson thanks for your help. I have made the change you suggested but then, the logs are saved in the "public" directory, not in the "storage" directory

elminson commented 4 months ago

@Delia-SimpleKYC not sure if you had run this command

php artisan vendor:publish \
  --provider="Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider"

but you need to copy this file to your config folder: https://github.com/rap2hpoutre/laravel-log-viewer/blob/master/src/config/logviewer.php and set LOGVIEWER_STORAGE_PATH env var in your .env file to point to your full log path

https://github.com/rap2hpoutre/laravel-log-viewer/blob/49c52ae197b3d4f7f9e43d328628edc4bc529afa/src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php#L44C1-L45C1

this line will look the storage_path in that order after those changes you should be able to do 'path' => 'eApply/eApply.log',

let me know if works ( I can try to replicate it in the next hours, this is just my guess)

Delia-SimpleKYC commented 4 months ago

@elminson but the default value of LOGVIEWER_STORAGE_PATH is the path to the logs (storage_path('logs')) ...

It still does not work with the change you suggested

Delia-SimpleKYC commented 4 months ago

@elminson @rap2hpoutre it seems to be related with this Pull Request: https://github.com/rap2hpoutre/laravel-log-viewer/pull/275

elminson commented 4 months ago

@Delia-SimpleKYC I will be testing the PR, and ask @rap2hpoutre if we can merge it (I may do some test cases to validate)

Delia-SimpleKYC commented 3 months ago

@rap2hpoutre @elminson any update on this issue?

elminson commented 3 months ago

@Delia-SimpleKYC I will be taking a deep look in to this week