This article mainly introduces the error log in PHP stored in the System log (Windows system), this article explained the setting method and view method, the need for friends can refer to the following
"Log errors to the system log"
In php.ini, set Error_log to:
Copy code code as follows:
Error_log = syslog
or use the Ini_set () function setting at run time.
"Example 1"
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17 |
<?php//Turn off error display Ini_set (' display_errors ', 0); Turn On Error log function ini_set (' log_errors ', ' on '); Set the path of the error log ini_set (' error_log ', ' syslog '); Show All Errors error_reporting (-1); Error in logging error//notification level echo $test; Warning Settype ($var, ' Dee '); Fatal error test (); |
To view the error log (Windows system):
My Computer----Right------Manage-----Event Viewer-----Information
"Example 2" sends the system log via Openlog ()
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14-15 16 |
<?php//Turn off error display Ini_set (' display_errors ', 0); Turn On Error log function ini_set (' log_errors ', ' on '); Set the path of the error log ini_set (' error_log ', ' syslog '); Show All Errors error_reporting (-1); Open the System log Connection Openlog (' PHP5.3.10 ', Log_pid, Log_syslog); Openlog:open connection to System logger//Send log syslog (Log_err, ' This is a test ' a syslog '. Date ("y-m-d h:i:s")); Turn off the System log Connection Closelog (); |
You can also see the log in the Event Viewer warning message: