I often read php error logs and rarely have the opportunity to write logs by myself. After Reading Wang Jian's "Best log practices", I think it is necessary to write clear and well-structured logs. Before writing logs, let's ask ourselves: Why do we sometimes need to record custom logs? Instead of using the system's default logging method? I think there are two
I often read php error logs and rarely have the opportunity to write logs by myself. After Reading Wang Jian's "Best log practices", I think it is necessary to write clear and well-structured logs. Before writing logs, let's ask ourselves: Why do we sometimes need to record custom logs? Instead of using the system's default logging method? I think there are two
I often read php error logs and rarely have the opportunity to write logs by myself. After Reading Wang Jian's "Best log practices", I think it is necessary to write clear and well-structured logs.
Before writing logs, let's ask ourselves: Why do we sometimes need to record custom logs? Instead of using the system's default logging method?
I think there are two reasons:
1. The team needs a uniform log format for easy management
2. A large number of useless error logs occupy hard disk space and only meaningful logs need to be recorded.
So, practice it.
1. Open your php. ini2. open the log and set
log_errors = Off
Change
log_errors = On
3. Save php. ini and restart the web server. 4. Add the following code at the beginning of your code:
1
5. Try to write an error code after the code.echo 1/0;
Check whether a log file exists in the defined path? :)
Note:The following errors cannot be handled by user-defined functions: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of the E_STRICT generated in the file where the set_error_handler () function is called.
However, when you enable the Error Log System (php. log_error = on in ini and specify the System Log File (also php. error_log = path name) in ini, and after error_reporting is enabled, all the above errors will be recorded in your defined file as system error logs.