PHP error Log Save

Source: Internet
Author: User
Tags php error php error log

Summary: PHP error log, can be saved locally, can also be saved in the remote directory, below we save in the local as an example.

PHP Error Log Save

related functions: error_log ($mes, $mes _type, $destination)

where $mes_type= 3 indicates that the error log is appended to the file instead of overwriting the original file

Case 1 :

<?phpdate_default_timezone_set ("asia/chongqing"), function Age_error ($erroro, $erromes) {echo <strong> Error level </strong>:<font color= ' red ' > '. $erroro. '   </font><br> ";   echo "<strong> error message </strong>:". $erromes;   $time =date ("y-m-d g:i:s"); Save the error message \ r \ n Enter a carriage return to the file $info = "error level:" $erroro. " "." Error message: ". $erromes." Time: "$time."   \ r \ n ";  Error_log ($info, 3, "error_log.txt"); } set_error_handler ("Age_error", e_user_notice);//The error level is usually: e_user_warning,e_user_notice,e_user_error $age = 700; echo "Age:" $age. " <br> ";  if ($age >100) {trigger_error ("too old, greater than"); exit ();} ?>

Run code, refresh multiple times, and the results are as follows:


age:700
Error Level : 1024x768
error Message : Too old, greater than


Open Error_log.txt

You can see the following effects:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/69/wKiom1dAVGaykaVqAABksmBwjrg776.png "title=" capture. PNG "alt=" Wkiom1davgaykavqaabksmbwjrg776.png "/>


This article is from "Uncle Wei Xiaobao" blog, please be sure to keep this source http://darmi.blog.51cto.com/11607923/1775738

PHP error Log Save

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.