php - Symfony生产模式错误报告和P​​OST值

标签 php symfony error-handling production

我使用的是Symfony 4,但我希望2和3都差不多。

快速独白处理程序的生产模式错误报告返回GET请求的完整请求URL,因此在开发过程中重现错误相当容易。

但是,如果这是POST请求,那么您会遇到麻烦,因为没有提供POST值。

我对错误处理和日志记录组件有所了解,但是没有立即发现的。

还有其他人遇到此问题并找到解决方案吗?

最佳答案

根据@Puya Sarmidani的评论,这就是我最后所做的:

config/services.yaml:

App\Services\MonologExtraProcessor:
    tags:
        - { name: monolog.processor }
        - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

src/Services/MonologExtraProcessor.php:
namespace App\Services;

use Symfony\Component\HttpKernel\Event\GetResponseEvent;

class MonologExtraProcessor
{
    private $postParams = null;

    public function __invoke(array $record)
    {
        if ($this->postParams !== null) {
            $record['extra']['postParams'] = $this->postParams;
        }
        return $record;
    }

    public function onKernelRequest(GetResponseEvent $event)
    {
        $postParams = $event->getRequest()->request->all();
        $this->postParams = empty($postParams) ? null : serialize($postParams);
    }
}

关于php - Symfony生产模式错误报告和P​​OST值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53408755/

相关文章:

python - python tkinter "calculator"的意外输出

c# - 如何处理调用方法中的错误

php - 404 Page Not Found 没有找到您请求的页面。代码点火器

php - 使用 `must implement interface Doctrine\ORM\EntityManagerInterface error` 将 EntityManagerInterface 注入(inject)我的服务

php - 如何在 PHP 中与 PKCS#11 兼容的 HSM 设备交互

php - 克隆 Doctrine 实体与相关的一对多实体

jquery - 使用户能够拥有自定义配置文件的最佳方式 - 例如 about.me 个人资料

asp.net-mvc - 如何在AuthorizeAttribute中设置viewbag?

php - 使用正则表达式更新 mysql 表

php - 无法将数据插入我的本地 mysql 服务器