In PHP, the error log is saved in the System log (Windows system) _php instance

Source: Internet
Author: User
Tags openlog syslog system log

"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"

<?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 Error
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 ()

<?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 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"));
Turn off the System log Connection
Closelog ();

You can also see the log in the Event Viewer warning message:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.