如何让 Xdebug 在打开页面时只显示回溯,而不记录回溯?
How to make Xdebug only show backtrace when opening page, and not log the backtrace?
Xdebug 目前在定义的 error_log 文件中记录整个回溯:
CustomLog /var/log/www/access.log combined
ErrorLog /var/log/www/error.log
php_value error_log /var/log/www/error.log
这很好。但是,它记录了太多。自从我安装了 Xdebug,它的日志是这样的:
[02-May-2016 16:14:20 Europe/Berlin] PHP Notice: Undefined variable: k in /var/www/index.php on line 30
[02-May-2016 16:14:20 Europe/Berlin] PHP Stack trace:
[02-May-2016 16:14:20 Europe/Berlin] PHP 1. {main}() /var/www/index.php:0
这将重复大约 10 次。我完全可以接受这样的错误消息:
[02-May-2016 16:14:20 Europe/Berlin] PHP Notice: Undefined variable: k in /var/www/index.php on line 30
打开时在页面上有完整的堆栈跟踪。可能吗?我找不到任何与仅记录消息相关的选项,并在页面上显示跟踪。
- PHP 版本 5.6.4
- xdebug 版本 2.4.0
XDebug 文档之后:
xdebug.default_enable = 0
Default value: 1
If this setting is 1, then stacktraces will be shown by default on an error event. You can disable showing stacktraces from your code with xdebug_disable(). As this is one of the basic functions of Xdebug, it is advisable to leave this setting set to 1.
我宁愿在 xdebug_disable()
的脚本树函数开头的某处使用适当的开关,以便可以打开和关闭它,具体取决于开发状态:
define('VERBOSE', /* from config/db/etc value of true/false */ false);
if(!VERBOSE) {
xdebug_disable();
}
如果您的服务器管理员不愿意更改生产环境配置,那么您的灵活性会更大一些。
Xdebug 目前在定义的 error_log 文件中记录整个回溯:
CustomLog /var/log/www/access.log combined
ErrorLog /var/log/www/error.log
php_value error_log /var/log/www/error.log
这很好。但是,它记录了太多。自从我安装了 Xdebug,它的日志是这样的:
[02-May-2016 16:14:20 Europe/Berlin] PHP Notice: Undefined variable: k in /var/www/index.php on line 30
[02-May-2016 16:14:20 Europe/Berlin] PHP Stack trace:
[02-May-2016 16:14:20 Europe/Berlin] PHP 1. {main}() /var/www/index.php:0
这将重复大约 10 次。我完全可以接受这样的错误消息:
[02-May-2016 16:14:20 Europe/Berlin] PHP Notice: Undefined variable: k in /var/www/index.php on line 30
打开时在页面上有完整的堆栈跟踪。可能吗?我找不到任何与仅记录消息相关的选项,并在页面上显示跟踪。
- PHP 版本 5.6.4
- xdebug 版本 2.4.0
XDebug 文档之后:
xdebug.default_enable = 0
Default value: 1
If this setting is 1, then stacktraces will be shown by default on an error event. You can disable showing stacktraces from your code with xdebug_disable(). As this is one of the basic functions of Xdebug, it is advisable to leave this setting set to 1.
我宁愿在 xdebug_disable()
的脚本树函数开头的某处使用适当的开关,以便可以打开和关闭它,具体取决于开发状态:
define('VERBOSE', /* from config/db/etc value of true/false */ false);
if(!VERBOSE) {
xdebug_disable();
}
如果您的服务器管理员不愿意更改生产环境配置,那么您的灵活性会更大一些。