如何使用Zend Log作为一个独立的组件?
我想使用 Zend Framwork 的 Log 机制作为一个单独的组件,这意味着我想要从 ZF 得到的只是 Log,我该怎么做?
I want to use Zend Framwork's Log mechanism as a separated component,that means all I want from ZF is just the Log, How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据这两个页面
Zend_Log
需要Zend_Exception
和以下这意味着您实际上只需要框架本身的以下内容
然后您应该能够将记录器用作独立组件。只需将上面列表中的
library
文件夹添加到您的包含路径中(Zend Framework 组件依赖于此)According to these two pages
Zend_Log
requiresZend_Exception
and the followingWhat this means is that you really only need the following from the framework itself
You should then be able to use the logger as a stand-alone component. Just add the
library
folder in the list above to your include path (Zend Framework components rely on this)每当我想使用 Zend Framework 中的各个组件时,我只需包含一个名为
zend_setup.php
的小文件,其中包含以下三行代码:这可能不如发出显式
require_once( )
语句,但我喜欢它提供的便利。例如,您可能很快决定还想使用Zend_Log_Writer_Firebug()
和Zend_Log_Writer_Mail()
。使用自动加载器可以避免编写所有额外的require_once()
语句。Whenever I want to use individual components from Zend Framework I simply include a small file called
zend_setup.php
that contains the following three lines of code:This is probably not as efficient as issuing explicit
require_once()
statements, but I like the convenience it offers. For example, you may very quickly decide you also want to utilizeZend_Log_Writer_Firebug()
andZend_Log_Writer_Mail()
. Using the autoloader avoids having to write all those additionalrequire_once()
statements.