It seems that the issue I am facing is straightforward but somehow the resolutions suggested here, here, and here are not working
I have got the following piece of code:
namespace App\Traits;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
...
try {
$response = Http::timeout(3)->get('google.cim');
} catch (\Illuminate\Http\Client\ConnectionException $e) {
Log::info('Connection refused #6 ');
}
I have already tried
- Using
\Illuminate\Http\Client\ConnectionException $e
- Using
\Exception $e
- Clearing cache
php artisan optimize:clear
But I just see the exception in the logs while my custom message never appears in the log.
Thank you.
Rather than catching a specific exception, try catching all exceptions using:
Also, check your
config/logging.php
file to make sure your logginglevel
is set correctly. It should bedebug
orinfo
:Don't forget to clear the config cache if you need to make change. Run:
php artisan config:clear
.