Can php print the error stack information to the error log like java?

Source: Internet
Author: User
Tags php exception handling php print
For the same question, what is the approximate operation procedure? Or is there any related information? Thank you. For the same question, what is the approximate operation procedure? Or is there any related information? Thank you.

Reply content:

For the same question, what is the approximate operation procedure? Or is there any related information? Thank you.

If you have any questions, clear them.

As I said downstairs, PHP does not output the error stack, but it can still get the error stack through functions.

function getBacktrace() {  ob_start();  debug_print_backtrace();  return ob_get_clean();}

Call the above function to get the error stack and use it againfile_put_contents('log_path', FILE_APPEND);Write the log file.

There is another way: install xdebug extension for PHP
Installation method under windows: http://www.cnblogs.com/qiantuwuliang/archive/2011/01/23/1942382.html
After installation, modify php. ini

log_errors = Onerror_log = "F://path/php_error.log"

When PHP logs are enabled, only the logs generated when PHP errors occur, such as syntax errors and warnings. @ Mongobj wants to log in the service and quickly locate the location where the error occurred in the framework. If you don't need a framework, you need to combine PHP exception handling and log class libraries to implement such a function. if you use the framework, almost all the full stack frameworks will support it.

You can checkdebug-backtraceAnddebug-print-backtrace.phpTwo functions: http://www.php.net/manual/en/function.debug-backtrace.phphttp://www.php.net/manual/en/function.debug-print-backtrace.php

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.