Save the error log in the system log in PHP
This article mainly introduces the error log in PHP stored in the System log (Windows system), this article explains the Setup 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 the 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 |
Turn off error display Ini_set (' Display_errors ', 0); Turn on the error log function Ini_set (' log_errors ', ' on '); Setting the path to the error log Ini_set (' error_log ', ' syslog '); Show All Errors Error_reporting (-1); Log errors Error at notification level Echo $test; Warning Settype ($var, ' Dee '); Fatal error Test (); |
To view the error log (Windows system):
My Computer----Right-click-----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 |
Turn off error display Ini_set (' Display_errors ', 0); Turn on the error log function Ini_set (' log_errors ', ' on '); Setting the path to the error log Ini_set (' error_log ', ' syslog '); Show All Errors Error_reporting (-1); Open the connection to the system log 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")); Shut down the System log connection Closelog (); |
You can also see the log in the Event Viewer warning message:
http://www.bkjia.com/PHPjc/1020271.html www.bkjia.com true http://www.bkjia.com/PHPjc/1020271.html techarticle In PHP, the error log is stored in the system log this article mainly introduces the error log in PHP stored in the System log (Windows system), this article explains the Setup method and the method of viewing, need ...