How to set Laravel to catch/log 500 errors from API?
I have Laravel 6.x and, in .env, I have APP_ENV=production
with APP_DEBUG=false
and a function with DB::table('table_doesnt_exists')->get()
.
If I access a web route from browser which call that function I see on the screen "500 Server Error" and the error is written in logs, which is perfect.
If use axios
and call an API route which call the same function I only get HTTP response 500, without any response, and most important there is no error in logs.
I have manage to make it works after trying multiple combinations.
APP_ENV=local
APP_DEBUG=false
The error is written in logs and the API only return
{ message: "Server Error" }