doumen6532 2011-08-17 16:26
浏览 57
已采纳

与Zend_Log_Writer_Firebug一起使用时,FirePHP不显示额外内容

I've been developing with Zend Framework for ages (since 0.9) and this problem is nagging at my nerves ever since.

I want to output messages on the FireBug Console with the help of FirePHP and from a Zend Framework 1.11 Application. I've configured Firebug with the default application.ini-file:

resources.log.firebug.writerName = "Firebug"
resources.log.firebug.filterName = "Priority"
resources.log.firebug.filterParams.priority = 7

I can now see messages in FireBug, e.g. in the IndexController, by calling an invalid action or by explicitly throwing Exceptions like

throw new Exception("This is my error message", E_USER_ERROR);

This results in the default ErrorController handling the Exception and showing a stack trace and request parameters:

Request Parameters

The default ErrorController will also log all messages automatically to FireBug:

Firebug Success

However, as you can see, the extra-information like the stack trace or the request parameters are not shown, although FireBug is quite able to do so, as may be seen in this Screenshot of FireBug when visiting the mainpage:

Detailed Firebug window

As the documentation states, Zend_Log_Writer_Firebug will ignore all writerParams, with which a defaultPriorityStyle may be set to TRACE or something similar.

Now for my question: Is there any way to configure Zend Framework to also send over the extra data (as shown in the last picture) without having to use firePHPcore, but with the tools coming with Zend Framework itself?

Best Regards and Thanks in Advance!

  • 写回答

1条回答 默认 最新

  • dongshungou7699 2011-08-19 00:14
    关注

    I think you cannot achieve what you're saying with the default error controller generated from zf create project because the lines involved are these

    // Log exception, if logger available
    if ($log = $this->getLog()) {
        $log->log($this->view->message, $priority, $errors->exception);
        $log->log('Request Parameters', $priority, $errors->request->getParams());
    }
    

    i.e. the default error controller only log the message, the priority and the exception and the firebug writer format them in the way you shown.

    To achieve what you're saying you should hack the Zend_Log_Writer_Firebug class to display the stacktrace using the firebug console or alternatively you can play with a custom formatter class added to your logger.

    I did something similar by creating a mail logger which displays formatted exception stacktrace in a mail message and use when in production to obtain a formatted log of the exception sent by email. You can find it here on Github and here you can find its usage.

    Moreover you can see an example on how to use the firebug console using the ZF classes in the Zend_Db_Profiler_Firebug class.

    So to answer your question, no you can't do that without writing some custom class and it as writer or formatter to the log object nor you can do that by just using the application.ini file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀