Laravel3 Study Notes (15th)

Source: Internet
Author: User
Tags php error

Original Author's blog: ieqi.net

========================================================== ========================================================== ================================

Exceptions and logs

In applications, we always encounter various problems and exceptions. At this time, it is very important to record the status when exceptions occur, so exceptions and logs are naturally related.

 

The exception and log configuration is in the application/config/error. php file.

The file contains four configuration items:

 
'Ignore' => array (), 'detail' => true, 'log' => false, 'logger '=> function ($ exception) {log :: exception ($ exception );},

Where the ignore key points to the array set the PHP error level that needs to be ignored, about the error level, you can refer to here (http://php.net/manual/en/function.error-reporting.php ).

The detail item indicates whether to display detailed error information. Generally, this item should be set to true during development and disabled in production.

If the log item is set to true, when an exception occurs, the Framework executes the anonymous function configured for the logger item. This provides great convenience for processing error logs. You can even set email notifications in anonymous functions. By default, log is enabled, the system will write error logs to log files under storage/logs, which are separated by days after installation.

In addition, if you want to write some information into the log file in the program, you can directly call the following method:

 
Log: Write ('info', 'this is just an informational message! '); // You can also write a simpler log: Info ('this is just an informational message! ');

 

Related Article

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.