How to write the wrong "number of lines" or complete error information of php into the file

Source: Internet
Author: User
Tags oauth openid php error sql error
Currently, only the rows with SQL errors can be written into text files. How can I write the rows with errors. Or write the php error message into the file. What I can do is to write the SQL error lines into the text file.

How can I write the wrong number of rows. Or write the php error message into the file.

Major solution direction

Reply content:

Currently, only lines with SQL errors can be written into text files.

How can I write the wrong number of rows. Or write the php error message into the file.

Major solution direction

  1. UseExceptionAn error occurred while carrying the object.
  2. Use the outermost layertry catchOrset_exception_handlerCapture and output both friendly errorsExceptionInformation (including the complete callstack, which has some parameters that may need to be simplified)
  3. Error can be convertedErrorExceptionSame Processing

For example, we use mongodb to record logs. This is an error of a certain day.

    "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\\\\WechatOauth\",\"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\/site\/20150130-150624\/vendor\/slim\/slim\/Slim\/Middleware\/MethodOverride.php:92",                    "\/data\/deploy\/site\/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\\AbstractLogger->warning() @ \/data\/deploy\/site\/20150130-150624\/src\/Router.php:194",                "#2 XXXX\\Site\\Router::XXXX\\Site\\{closure}() @ :",                "#3 call_user_func_array() @ \/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/Slim\/Slim.php:656",                "#4 Slim\\Slim->callErrorHandler() @ \/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/Slim\/Slim.php:638",                "#5 Slim\\Slim->error() @ \/data\/deploy\/site\/20150130-150624\/vendor\/slim\/slim\/Slim\/Slim.php:1347",                "#6 Slim\\Slim->call() @ \/data\/deploy\/site\/20150130-150624\/vendor\/slim\/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\\MethodOverride->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": 300,        "level_name": "WARNING",        "channel": "main",        "datetime": {            "sec": 1423037667,            "usec": 0        },        "extra": []    },

The login judgment is inaccurate. Trust the notice caused by the openid returned result. You can see it without looking at the code.

Error_log (), OK?

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.