How can i get all text and sentences (content) from laravel.log file?
this below code is not working for me :
error_reporting(E_ALL);
$logs = fopen("storage\logs\laravel.log", "r") or die("Unable to open file!");
echo fread($logs, filesize("laravel.log"));
fclose($logs);
return response()->json($logs);
and my error :
fopen(storage/logs/laravel.log): Failed to open stream: No such file or directory
Thank you for your guidance.
CodePudding user response:
Access using
$logPath = storage_path().'/logs/laravel.log';
$logs = fopen($logPath , "r") or die("Unable to open file!");
And make sure laravel.log exists.