php - Is there a way to log Laravel debug screen details when the app is not in debug mode?
So I have a laravel app where currently there are some errors like the following:
The app is in debug mode so I can see the error details. If I set debug=false
then Laravel only shows a 500 error screen.
Is there a way I can set debug as false and log these details when the error occurs?
There are two things here:
I know this is not optimal, we should resolve all the bugs before going to production. But legacy and other reasons behind this choice.
I know we can write explicit logs, but I was wondering if there is a generic way that each time Laravel encounters such errors it can log (or better yet email!) the details.
I am new to Laravel so any help/insight here is much appreciated.
Thank you all!
Answer
Solution:
If you show debug logs while in production, an attacker can force your application to crash, therefore showing stack traces, environment variables and much more.
The only solution I can think of is to write logs as you have mentioned. As far as I'm aware, there are no packages that do what you are looking for (emailing you when an error occurs).
What you are looking for is services that monitor your application and notifies you. A few I can think of:
Source