Zend_Log 在 application.ini 中
有没有示例如何从 application.ini 设置 zend log 实例?我只找到了登录到文件的示例,但我想登录到 SQLITE 数据库表?
is there any example how to setup an instance of zend log from application.ini? I have only found an example for logging to an file, but i want to log into an SQLITE database table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好问题。我找不到从引导配置实例化
Zend_Log_Writer_Db
的方法。 writer 类需要一个Zend_Db_Adapter
对象。它不接受字符串。采埃孚项目需要进一步开发这个用例。他们甚至没有任何包含 Db writer 的
Zend_Application_Resource_Log
单元测试。在此之前我能建议的最好的建议是,Bootstrap 类需要在
_initLog()
方法中自定义日志资源。Good question. I can't find a way to instantiate the
Zend_Log_Writer_Db
from a bootstrap config. The writer class requires aZend_Db_Adapter
object. It doesn't accept a string.The ZF project needs to develop this use case further. They don't even have any unit tests for
Zend_Application_Resource_Log
that include a Db writer.The best I can suggest until then is that you Bootstrap class needs to customize the Log resource in an
_initLog()
method.在手册中:你可以找到一个如何将日志文件写入数据库的示例。这是你的意思吗?
Here in the manual: you can find an example how to write your log file into the database.Is that what you mean?
这应该可行 - 我稍后将进行全面测试(现在不在我的开发机器上)
Zend_Application_Resource_Log 可以从 application.ini 设置 Zend_Log 的实例
This should work - I will test fully later (not at my dev machine now)
Zend_Application_Resource_Log can setup an instance of a Zend_Log from application.ini
自 ZF 1.10alpha(至少)以来,以下情况都是正确的。
注意:任意数组键“firebug”。当 Zend_Log 工厂搅动资源的日志配置时,示例 1 将作为数组传递给 Zend_Log->addWriter() (触发 _constructWriterFromConfig() 方法),而示例 2 将简单地传递一个字符串(触发异常)。
(我知道这已经很旧了,我正在使用 Firebug 记录器示例,但这同样适用于所有日志编写器)
Since ZF 1.10alpha (at least), the following has been true.
NOTE: the arbitrary array key 'firebug'. When the Zend_Log factory churns over the resource's log config, example 1 will be passed as an array to Zend_Log->addWriter() (triggering the _constructWriterFromConfig() method), whilst example 2 will simply pass a string (triggering an exception).
(I know this is old, and I'm using a Firebug logger example, but the same applies to all log writers)