This article mainly introduces how to save the error log in the System Log (Windows System) in PHP. This article describes how to set and view the error log. For more information, see
[Record errors to system logs]
In php. ini, set error_log:
The Code is as follows:
Error_log = syslog
Or you can use the ini_set () function to set it during running.
[Example 1]
<? Php // disable the error display ini_set ('display _ errors ', 0); // enable the error log function ini_set ('Log _ errors', 'on '); // set the error log Path ini_set ('error _ log', 'syslog '); // display all error error_reporting (-1 ); // record error // notification-Level Error echo $ test; // warning settype ($ var, 'dee'); // fatal error test ();
View error logs (Windows ):
"My Computer" ---- right-click ----- manage ----- Event Viewer ----- Information
[Example 2] Use openlog () to send system logs
<? Php // disable the error display ini_set ('display _ errors ', 0); // enable the error log function ini_set ('Log _ errors', 'on '); // set the error log Path ini_set ('error _ log', 'syslog '); // display all error 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 of a syslog '. date ("Y-m-d H: I: s"); // close the system log connection closelog ();
Logs can also be seen in the Event Viewer warning information: