Save the error log in the System Log in PHP (Windows System)

Source: Internet
Author: User
Tags openlog
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

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:

,

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.