How to write a PHP error "line number" or complete error message into the file

Source: Internet
Author: User
Tags oauth openid try catch
All you can do now is write the number of rows of SQL errors into a text file

How do I write the wrong number of lines in the same way? Or would you like to write the entire PHP error message in the file?

The solution gives a big direction.

Reply content:

All you can do now is write the number of rows of SQL errors into a text file

How do I write the wrong number of lines in the same way? Or would you like to write the entire PHP error message in the file?

The solution gives a big direction.

    1. Exceptionload the error with the object and throw it out
    2. The outermost use try catch or set_exception_handler capture, the output of friendly errors while recording Exception information (including the full callstack, which has all the parameters, may be very large need to streamline)
    3. Error can be converted to ErrorException walk the same processing

For example, I plant through MongoDB to record the log, which is a certain day error

    "54d1d4e39dce4f834949f0e9": {"_id": {"$id": "54d1d4e39dce4f834949f0e9"}, "message": "Site.error", "context": {"UID": null, "uri": "\/login\/wechat\/get-userinfo", "                Exception ": {" Class ":" Errorexception "," message ":" Undefined Index:openid ", "File": "\/data\/deploy\/site\/20150130-150624\/src\/controller\/passport\/oauth\/wechatoauth.php:102", " Trace ": [" \/data\/deploy\/site\/20150130-150624\/src\/controller\/passport\/oauth\/wechatoauth.php:102 "," {\ "function\": \ "getuserinfo\", \ "class\": \ "Xxxx\\\\site\\\\controller\\\\passport\\\\oauth\\\\wechat Oauth\ ", \" type\ ": \":: \ ", \" Args\ ": []}", "\/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/slim                    \/route.php:462 "," \/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/slim\/slim.php:1326 ", "\/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/slim\/middleware\/flash.php:85 "," \/data\/deploy\/s Ite\/20150130-150624\/vendor\/slim\/slim\/slim\/middleware\/methodoverride.php:92 "," \/data\/deploy\/si te\/20150130-150624\/vendor\/slim\/slim\/slim\/slim.php:1271 "," \/data\/deploy\/site\/20150130-150624\/ Public\/index.php:11 "]}," _trace ": [" #0 Xxxx\\log\\log->log () @ \/data\/deploy\/site\/20150130-150624\/vendor\/psr\/log\/psr\/log\/abstractlogger.php:80 "," #1 Psr\\Log\\Ab Stractlogger->warning () @ \/data\/deploy\/site\/20150130-150624\/src\/router.php:194 "," #2 XXXX\\Site\\R Outer::xxxx\\site\\{closure} () @: "," #3 Call_user_func_array () @ \/data\/deploy\/site\/20150130-150624\/ve ndor\/slim\/slim\/slim\/slim.php:656 "," #4 Slim\\slim->callerrorhandler () @ \/data\/deploy\/site\/201501 30-150624\/vendor\/slim\/slim\/slim\/slim.php:638 "," #5 slim\\slim->error () @ \/data\/deploy\/site\/20150130-150624\/vendor\/sli m\/slim\/slim\/slim.php:1347 "," #6 Slim\\slim->call () @ \/data\/deploy\/site\/20150130-150624\/vendor\/s Lim\/slim\/slim\/middleware\/flash.php:85 "," #7 Slim\\middleware\\flash->call () @ \/data\/deploy\/site\/ 20150130-150624\/vendor\/slim\/slim\/slim\/middleware\/methodoverride.php:92 "," #8 Slim\\Middleware\\Method Override->call () @ \/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/slim\/slim.php:1271 "," #9            Slim\\slim->run () @ \/data\/deploy\/site\/20150130-150624\/public\/index.php:11 "," #10 {main} "            ]}, "Level": "Level_name": "WARNING", "channel": "Main", "datetime": { "SEC": 1423037667, "USEC": 0}, "Extra": []},

Landing judgment is not accurate, trust return results have OpenID caused by notice, do not look at the code can see it

Error_log (), can you?

  • 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.