Laravel a daily Diary

Source: Internet
Author: User

Recently in the use of laravel development projects, the more convenient to use the feeling, although the official website to explain the content of the document a little, but practical or some.


Today should be asked to record the error of the request into the log, at first I was directly inStart/Global.PHPAdd Log::error ($exception), and then change the return parameters of the request, the error occurs as expected, but did not see the error record written into the log, the log file is also configured in the global file.

Then I remembered that I had been inapp/Errors.PHPThe processing of 500 and 404 is configured, and the error page is returned, so the log operation to global can not be performed, so the error log operation is also logged under error.php. Then there is a suggestion that the ' debug ' in the config/app.php is set to false in the online product, because if an error occurs before the error.php processing error, it will return to the familiar stack trace, which is very bad for the user.


Here's a look at the Laravel documentation:

The Laravel log tool is built on a powerful Monolog library and provides a simple layer of abstraction. By default, Laravel creates a separate log file for the app, and the path to the file is app/storage/laravel.log . You can output the log by using the following method:

Log:: Info( ' This is some useful information. ');Log:: warning( ' Something could be going wrong. ');Log:: error( ' Something is really going wrong. ');
We can use a variety of information skillfully.

Of course, the direct Log::error ($exception) recorded things do not look good, you can use a variety of ways you like to take the information you need to record, such as:

$err = [' message ' = = $exception->getmessage (), ' line ' = ' $exception->getline ()]; Log::error ($err);

This way, it should be easier to see.

Finally recommend the expansion package, Laravel-ide-helper, developed with the IDE is very useful, as if sublime also have, https://laracasts.com/series/ HOW-TO-BE-AWESOME-IN-PHPSTORM/EPISODES/15 is the introduction of the use and installation methods, can be installed with composer, as if Phpstorm plugin can also search out the installation.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Laravel a daily Diary

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.