I want to add log monitoring to some of the running points in my program and use them directly
file_put_contents
Can be executed to a point where the information is recorded, but it cannot save the output of the program format, write the saved data is the form of text, can not be saved such as in the browser directly printed array format or
json
Format it! That's how I write it.
file_put_contents("../fileLog/{$time}.log", $error);
It is desirable to be able to save the full data format and to accumulate error messages. For you.
Reply content:
I want to in my own program some of the operating point of the log monitoring, direct use file_put_contents
can be executed to a certain point of the place to record the information, but cannot save the output of the program format, write the saved data is the form of text, can not be saved such as in the browser directly printed array format or json
Format It! That's how I write it.
file_put_contents("../fileLog/{$time}.log", $error);
It is desirable to be able to save the full data format and to accumulate error messages. For you.
You can use var_export()
the output of your error message. If you want to accumulate records file_put_contents
have corresponding parameters, set up can also support the accumulation of line, and then give you the error message system time, can better view the error time and error messages. For example
file_put_contents("../fileLog/{$time}.log", var_export($error, true) . "【Time:" . date("Y-m-d H:i:s") . '】' . PHP_EOL, FILE_APPEND);
However, the addition of this time will also cause your log log file error data information becomes more and more large. Pay attention to clean up in time. Hope to help you
Search the Seaslog. This log extension
To meet your needs.