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
- Use
Exception
An error occurred while carrying the object.
- Use the outermost layer
try catch
Orset_exception_handler
Capture and output both friendly errorsException
Information (including the complete callstack, which has some parameters that may need to be simplified)
- Error can be converted
ErrorException
Same 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?