Zend_登录application.ini [英] Zend_Log in application.ini
问题描述
有没有示例如何从application.ini设置zend日志的实例?我只找到了登录文件的示例,但是我想登录到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?
推荐答案
好问题.我找不到从引导程序配置实例化Zend_Log_Writer_Db
的方法. writer类需要一个Zend_Db_Adapter
对象.它不接受字符串.
Good question. I can't find a way to instantiate the Zend_Log_Writer_Db
from a bootstrap config. The writer class requires a Zend_Db_Adapter
object. It doesn't accept a string.
ZF项目需要进一步开发此用例.他们甚至没有对Zend_Application_Resource_Log
进行任何包含Db编写器的单元测试.
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.
在此之前,我最好的建议是您的Bootstrap类需要使用_initLog()
方法自定义Log资源.
The best I can suggest until then is that you Bootstrap class needs to customize the Log resource in an _initLog()
method.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDb()
{
if ($this->hasPluginResource("db")) {
$r = $this->getPluginResource("db");
$db = $r->getDbAdapter();
Zend_Registry::set("db", $db);
}
}
protected function _initLog()
{
if ($this->hasPluginResource("log")) {
$r = $this->getPluginResource("log");
$log = $r->getLog();
$db = Zend_Registry::get("db");
$writer = new Zend_Log_Writer($db, "log", ...columnMap...);
$log->addWriter($writer);
Zend_Registry::set("log", $log);
}
}
}
这篇关于Zend_登录application.ini的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!