Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 是否在system.log中添加调试跟踪?_Php_Magento_Debugging_Warnings - Fatal编程技术网

Php 是否在system.log中添加调试跟踪?

Php 是否在system.log中添加调试跟踪?,php,magento,debugging,warnings,Php,Magento,Debugging,Warnings,此错误将继续填充system.log: 2016-03-27T13:59:10+00:00 ERR (3): Warning: simplexml_load_string(): Entity: line 12: parser error : Premature end of data in tag config line 2 in /home/xxxx/public_html/lib/Varien/Simplexml/Config.php on line 510 每隔几分钟或几小时。为了找到

此错误将继续填充system.log:

2016-03-27T13:59:10+00:00 ERR (3): Warning: simplexml_load_string(): Entity: line 12: parser error : Premature end of data in tag config line 2  in /home/xxxx/public_html/lib/Varien/Simplexml/Config.php on line 510
每隔几分钟或几小时。为了找到罪魁祸首,我尝试在Config.php中添加以下内容:

file_put_contents('/home/xxxx/public_html/xml_errors/'.sha1(microtime(true)).'.txt', $string . PHP_EOL . '=====' . PHP_EOL . print_r(debug_backtrace(), true));
$xml = simplexml_load_string($string, $this->_elementClass);
在Config.php的510行之前:

file_put_contents('/home/xxxx/public_html/xml_errors/'.sha1(microtime(true)).'.txt', $string . PHP_EOL . '=====' . PHP_EOL . print_r(debug_backtrace(), true));
$xml = simplexml_load_string($string, $this->_elementClass);
由于我的商店非常繁忙,而且我仍然不知道如何精确定位引发警告的
$string
,因此每秒可以快速创建5-10个文件

如何自定义system.log以提供警告的调试跟踪,以便跟踪传递给Config.php的xml字符串的实际来源


或者任何其他关于查找无效XML源的建议都将不胜感激

我可以通过添加到有问题的行来追溯:

$xml = simplexml_load_string($string, $this->_elementClass);
像这样:

set_error_handler("warning_handler", E_WARNING);
$xml = simplexml_load_string($string, $this->_elementClass);
restore_error_handler();
然后在Config.php文件末尾添加一个独立函数:

function warning_handler($errno, $errstr, $errfile, $errline) {
    file_put_contents('/home/xxxx/public_html/xml_errors/'.sha1(microtime(true)).'.txt', print_r(debug_backtrace(), true));
}

当然,您必须手动创建文件夹xml\u errors。

我可以通过添加到有问题的行来追溯:

$xml = simplexml_load_string($string, $this->_elementClass);
像这样:

set_error_handler("warning_handler", E_WARNING);
$xml = simplexml_load_string($string, $this->_elementClass);
restore_error_handler();
然后在Config.php文件末尾添加一个独立函数:

function warning_handler($errno, $errstr, $errfile, $errline) {
    file_put_contents('/home/xxxx/public_html/xml_errors/'.sha1(microtime(true)).'.txt', print_r(debug_backtrace(), true));
}
当然,您必须手动创建文件夹xml\u