从错误日志中了解堆栈跟踪? (Magento) [英] Understading stack trace from error log? (Magento)

查看:46
本文介绍了从错误日志中了解堆栈跟踪? (Magento)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有关如何阅读和理解堆栈跟踪的指南. 在这种情况下,人们在尝试填写和发送联系表时会遇到错误.而且我真的很难解决这个问题,当我无法解密堆栈时,这并不容易. (这是一个magento 1.6.2安装)

正在发送电子邮件,但是联系表告诉用户有问题,因此我们从反复尝试的人们那里得到很多重复.

exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. mail(/var/www/site.dk/logs/php-maillog.log): failed to open stream: Permission denied' in /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Sendmail.php:137
Stack trace: 
#0 /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Abstract.php(348):      Zend_Mail_Transport_Sendmail->_sendMail()
#1 /var/www/site.dk/public_html/lib/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#2 /var/www/site.dk/public_html/app/code/core/Mage/Core/Model/Email/Template.php(409): Zend_Mail->send()
#3 /var/www/site.dk/public_html/app/code/core/Mage/Core/Model/Email/Template.php(462): Mage_Core_Model_Email_Template->send('email@email.com', NULL, Array)
#4 /var/www/site.dk/public_html/app/code/core/Mage/Contacts/controllers/IndexController.php(104): Mage_Core_Model_Email_Template->sendTransactional('1', 'general', 'email@email.com', NULL, Array)
#5 /var/www/site.dk/public_html/app/code/local/Mage/Core/Controller/Varien/Action.php(420): Mage_Contacts_IndexController->postAction()
#6 /var/www/site.dk/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('post')
#7 /var/www/site.dk/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /var/www/site.dk/public_html/app/code/local/Mage/Core/Model/App.php(348): Mage_Core_Controller_Varien_Front->dispatch()
#9 /var/www/site.dk/public_html/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#10 /var/www/site.dk/public_html/shop/index.php(80): Mage::run('store...', 'store')
#11 {main}

sendmail.php中的代码段

public function _sendMail()
{
    if ($this->parameters === null) {
        set_error_handler(array($this, '_handleMailErrors'));
        $result = mail(
            $this->recipients,
            $this->_mail->getSubject(),
            $this->body,
            $this->header);
        restore_error_handler();
    } else {
        if(!is_string($this->parameters)) {
            /**
             * @see Zend_Mail_Transport_Exception
             * 
             * Exception is thrown here because
             * $parameters is a public property
             */
            #require_once 'Zend/Mail/Transport/Exception.php';
            throw new Zend_Mail_Transport_Exception(
                'Parameters were set but are not a string'
            );
        }

        set_error_handler(array($this, '_handleMailErrors'));
        $result = mail(
            $this->recipients,
            $this->_mail->getSubject(),
            $this->body,
            $this->header,
            $this->parameters);
        restore_error_handler();
    }

    if ($this->_errstr !== null || !$result) {
        /**
         * @see Zend_Mail_Transport_Exception
         */
        #require_once 'Zend/Mail/Transport/Exception.php';
       (137) throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr);
    }
}

解决方案

我打算将其写为注释,但是对于注释框来说太长了.

如果我们逐行浏览堆栈跟踪,您将开始了解发生了什么:

exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. mail(/var/www/site.dk/logs/php-maillog.log): failed to open stream: Permission denied' in /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Sendmail.php:137

首先,异常类型为Zend_Mail_Transport_Exception,这将使我们对从何处开始查找有所了解.在这种情况下,这是Zend_Mail代码中某处发生的错误.

第二,消息'Unable to send mail. mail(/var/www/site.dk/logs/php-maillog.log): failed to open stream: Permission denied'.对我来说,这似乎很清楚,当试图打开php-maillog.log时,我们收到了权限被拒绝的错误.是什么原因造成的?那是您必须确定的.

第三,我们向我们展示实际发生异常的位置/var/www/site.dk/public_html/lib/Zend/Mail/Transport/Sendmail.php:137.正如您所指出的,它发生在Sendmail.php的137行上.

其余的堆栈跟踪是PHP用来获取错误的路径.就是说,哪个函数调用了什么才能到达您看到异常的地方.据报道,这是从最后一件要添加到堆栈中的事情开始的,直到回到第一件为止,因此您几乎可以通过函数调用来追溯代码.

在这种情况下,您可以看到/var/www/site.dk/public_html/lib/Zend/Mail/Transport/Abstract.php的第348行的代码称为_sendMail函数,该代码例外.........第348行的代码由/var/www/site.dk/public_html/lib/Zend/Mail.php中的第1194行的代码调用,依此类推. /p>

TL:DR?

Magento在打开/var/www/site.dk/logs/php-maillog.log文件时遇到问题.是否为此文件正确设置了权限? /var/www/site.dk/logs/目录是否存在?

I've been looking for guides on how to read and understand a stack trace. In this case, people are getting errors when trying to fill out and send an contact form. And I'am really having trouble fixing this, and it's not any easier when I cannot decipher the stack. (This is a magento 1.6.2 installation)

The email are being sent, but the contact form tells the user that there was a problem, so we get alot of duplicates from people trying again, and again.

exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. mail(/var/www/site.dk/logs/php-maillog.log): failed to open stream: Permission denied' in /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Sendmail.php:137
Stack trace: 
#0 /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Abstract.php(348):      Zend_Mail_Transport_Sendmail->_sendMail()
#1 /var/www/site.dk/public_html/lib/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#2 /var/www/site.dk/public_html/app/code/core/Mage/Core/Model/Email/Template.php(409): Zend_Mail->send()
#3 /var/www/site.dk/public_html/app/code/core/Mage/Core/Model/Email/Template.php(462): Mage_Core_Model_Email_Template->send('email@email.com', NULL, Array)
#4 /var/www/site.dk/public_html/app/code/core/Mage/Contacts/controllers/IndexController.php(104): Mage_Core_Model_Email_Template->sendTransactional('1', 'general', 'email@email.com', NULL, Array)
#5 /var/www/site.dk/public_html/app/code/local/Mage/Core/Controller/Varien/Action.php(420): Mage_Contacts_IndexController->postAction()
#6 /var/www/site.dk/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('post')
#7 /var/www/site.dk/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#8 /var/www/site.dk/public_html/app/code/local/Mage/Core/Model/App.php(348): Mage_Core_Controller_Varien_Front->dispatch()
#9 /var/www/site.dk/public_html/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#10 /var/www/site.dk/public_html/shop/index.php(80): Mage::run('store...', 'store')
#11 {main}

The snippet from sendmail.php

public function _sendMail()
{
    if ($this->parameters === null) {
        set_error_handler(array($this, '_handleMailErrors'));
        $result = mail(
            $this->recipients,
            $this->_mail->getSubject(),
            $this->body,
            $this->header);
        restore_error_handler();
    } else {
        if(!is_string($this->parameters)) {
            /**
             * @see Zend_Mail_Transport_Exception
             * 
             * Exception is thrown here because
             * $parameters is a public property
             */
            #require_once 'Zend/Mail/Transport/Exception.php';
            throw new Zend_Mail_Transport_Exception(
                'Parameters were set but are not a string'
            );
        }

        set_error_handler(array($this, '_handleMailErrors'));
        $result = mail(
            $this->recipients,
            $this->_mail->getSubject(),
            $this->body,
            $this->header,
            $this->parameters);
        restore_error_handler();
    }

    if ($this->_errstr !== null || !$result) {
        /**
         * @see Zend_Mail_Transport_Exception
         */
        #require_once 'Zend/Mail/Transport/Exception.php';
       (137) throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr);
    }
}

解决方案

I was going to write this as a comment, but it's going to be too long for the comment box.

If we go through the stack trace line by line you will start to understand what's going on:

exception 'Zend_Mail_Transport_Exception' with message 'Unable to send mail. mail(/var/www/site.dk/logs/php-maillog.log): failed to open stream: Permission denied' in /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Sendmail.php:137

Firstly, the exception type, it's Zend_Mail_Transport_Exception which will give us an idea on where to start looking. In this case it's an error occurring somewhere in the Zend_Mail code.

Secondly, the message 'Unable to send mail. mail(/var/www/site.dk/logs/php-maillog.log): failed to open stream: Permission denied'. To me, this seems pretty clear, we are getting a permission denied error when the php-maillog.log is trying to be opened. What's causing this? That's what you will have to determine.

Thirdly, we are shown where the exception is actually occurring /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Sendmail.php:137. So it's occurring on line 137 of the Sendmail.php as you have noted.

The rest of the stack trace is the path that PHP took to get to the error. That is, which function called what to get to the point where you are seeing the exception. This is reported from the last thing to be added onto the stack, back to the first, so you are pretty much tracing your code backwards through the function calls.

In this case, you can see that the code on line 348 of /var/www/site.dk/public_html/lib/Zend/Mail/Transport/Abstract.php called the _sendMail function which exceptioned...the line 348 code was called by the code on line 1194 in /var/www/site.dk/public_html/lib/Zend/Mail.php and so on.

TL:DR?

Magento is having an issue opening the /var/www/site.dk/logs/php-maillog.log file. Are the permissions set correctly for this file? Does the /var/www/site.dk/logs/ directory exist?

这篇关于从错误日志中了解堆栈跟踪? (Magento)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆