Zend Log - 错误日志优先级

发布于 2024-12-03 21:10:27 字数 2209 浏览 1 评论 0原文

当我尝试将 registerErrorHandler() 添加到引导程序中的日志配置时,会出现以下错误:

<b>Fatal error</b>:  Uncaught exception 'Zend_Log_Exception' with message 'Bad log priority' in /public/fb/library/Zend/Log.php:280
Stack trace:
#0 /public/fb/application/Bootstrap.php(24):    Zend_Log-&gt;__call('registerErrorHa...', Array)
#1 /public/fb/application/Bootstrap.php(24): Zend_Log-&gt;registerErrorHandler()
#2 /public/fb/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap-&gt;_initLogging()
#3 /public/fb/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract-&gt;_executeResource('logging')
#4 /public/fb/library/Zend/Application/Bootstrap/BootstrapAbstract.php(583): Zend_Application_Bootstrap_BootstrapAbstract-&gt;_bootstrap(NULL)
#5 /public/fb/library/Zend/Application.php(355): Z in       

<b>/public/fb/library/Zend/Log.php</b> on line    <b>280</b>

Bootstrap.php

protected function _initLogging(){

$log = new Zend_Log();
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH .'/../data/logs/app.log');
$log->addWriter($writer);
$log->registerErrorHandler();

}

Output Zend_Debug::dump($log):

object(Zend_Log)#20 (6) {
["_priorities":protected] => array(8) {
[0] => string(5) "EMERG"
[1] => string(5) "ALERT"
[2] => string(4) "CRIT"
[3] => string(3) "ERR"
[4] => string(4) "WARN"
[5] => string(6) "NOTICE"
[6] => string(4) "INFO"
[7] => string(5) "DEBUG"
}
["_writers":protected] => array(1) {
[0] => object(Zend_Log_Writer_Stream)#21 (3) {
["_stream":protected] => resource(59) of type (stream)
["_filters":protected] => array(0) {
}
["_formatter":protected] => object(Zend_Log_Formatter_Simple)#22 (1) {
["_format":protected] => string(51) "%timestamp% %priorityName% (%priority%): %message%"   
}}}
["_filters":protected] => array(0) {
}
["_extras":protected] => array(0) {
}
["_defaultWriterNamespace":protected] => string(15) "Zend_Log_Writer"
["_defaultFilterNamespace":protected] => string(15) "Zend_Log_Filter"
}

谢谢帮助。

When I try to add a registerErrorHandler() to my log config in my bootstrap it gives the following error:

<b>Fatal error</b>:  Uncaught exception 'Zend_Log_Exception' with message 'Bad log priority' in /public/fb/library/Zend/Log.php:280
Stack trace:
#0 /public/fb/application/Bootstrap.php(24):    Zend_Log->__call('registerErrorHa...', Array)
#1 /public/fb/application/Bootstrap.php(24): Zend_Log->registerErrorHandler()
#2 /public/fb/library/Zend/Application/Bootstrap/BootstrapAbstract.php(666): Bootstrap->_initLogging()
#3 /public/fb/library/Zend/Application/Bootstrap/BootstrapAbstract.php(619): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('logging')
#4 /public/fb/library/Zend/Application/Bootstrap/BootstrapAbstract.php(583): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL)
#5 /public/fb/library/Zend/Application.php(355): Z in       

<b>/public/fb/library/Zend/Log.php</b> on line    <b>280</b>

Bootstrap.php

protected function _initLogging(){

$log = new Zend_Log();
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH .'/../data/logs/app.log');
$log->addWriter($writer);
$log->registerErrorHandler();

}

Output Zend_Debug::dump($log):

object(Zend_Log)#20 (6) {
["_priorities":protected] => array(8) {
[0] => string(5) "EMERG"
[1] => string(5) "ALERT"
[2] => string(4) "CRIT"
[3] => string(3) "ERR"
[4] => string(4) "WARN"
[5] => string(6) "NOTICE"
[6] => string(4) "INFO"
[7] => string(5) "DEBUG"
}
["_writers":protected] => array(1) {
[0] => object(Zend_Log_Writer_Stream)#21 (3) {
["_stream":protected] => resource(59) of type (stream)
["_filters":protected] => array(0) {
}
["_formatter":protected] => object(Zend_Log_Formatter_Simple)#22 (1) {
["_format":protected] => string(51) "%timestamp% %priorityName% (%priority%): %message%"   
}}}
["_filters":protected] => array(0) {
}
["_extras":protected] => array(0) {
}
["_defaultWriterNamespace":protected] => string(15) "Zend_Log_Writer"
["_defaultFilterNamespace":protected] => string(15) "Zend_Log_Filter"
}

Thx for helping.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧情别恋 2024-12-10 21:10:27

该错误是在 Zend_Log::__call() 魔术方法中引发的。由于使用了 __call() ,这意味着引用的方法在对象中不显式存在,因此 PHP 调用了对象的 __call() 魔术方法。

您确定调用方法的名称没有拼写错误吗?

您确定您使用的 ZF 版本确实支持此方法吗?我检查了我的 ZF 安装 (1.11.4),并在 Zend/Log.php 文件的第 280 行上发现了与此问题无关的其他内容。

将 ZF 安装更新到最新版本可能会有所帮助。

The error is thrown in Zend_Log::__call() magic method. since __call() is being used, this means that the referenced method does not exist in the object explicitly, so PHP has called the object's __call() magic method.

Are you sure there is no typo in the name of the method right where you are calling it?

Are you sure the version of ZF you are using actually supports this method? I checked my ZF installation (1.11.4) and on line 280 of Zend/Log.php file there is something else not related to this issue.

Updating your ZF installation to the last version could be helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文