In an online production environment, programs will inevitably encounter errors and exceptions.
We will not find most of these errors and exceptions, so how to automatically obtain these errors and exceptions?
That is, as long as the program encounters errors and exceptions, it will write these errors and exceptions to the Log for recording?
Thank you!
In an online production environment, programs will inevitably encounter errors and exceptions.
We will not find most of these errors and exceptions, so how to automatically obtain these errors and exceptions?
That is, as long as the program encounters errors and exceptions, it will write these errors and exceptions to the Log for recording?
Thank you!
This requires configuring PHP
log_errors=On
error_log=Log path
PHP will automatically write to the log when an error occurs.
set_error_handler
: Set user-defined error handling function
set_exception_handler
: Set user-defined exception handling function
The two functions set_exception_handler and set_error_handler can handle uncaught exceptions, then analyze and classify the exception information and write it to the log