firephp很好用,那怎麼跟log4php結合咧
download: 下載 利用ci寫的
由於ci使用library都得用new實體化
而log4php透過static method(getLogger)取得logger
用起來總是卡卡... 應該說會卡住...
所以寫成library
download: 下載 利用ci寫的
由於ci使用library都得用new實體化
而log4php透過static method(getLogger)取得logger
用起來總是卡卡... 應該說會卡住...
所以寫成library
- FirePHP appender
簡單說,就是多寫個FirePHP的Appender
這樣log4php就可以使用FirePHP
class LoggerAppenderFirePHP extends LoggerAppender { ... public function append(LoggerLoggingEvent $event) { if($this->layout !== null) return; $ci = & get_instance(); $level = $event->getLevel(); if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) { $ci->fb->error($this->layout->format($event)); } else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) { $ci->fb->warn($this->layout->format($event)); } else { $ci->fb->info($this->layout->format($event)); } } }
- config
<configuration xmlns="http://logging.apache.org/log4php/"> <appender name="firephp" class="LoggerAppenderFirePHP"> <layout class="LoggerLayoutPattern"> <param name="ConversionPattern" value="%m"/> </layout> </appender> <root> <appender_ref ref="firephp" /> </root> </configuration>
- logging
$this->load->library('Log4php'); $this->log4php->log('info',"[behavior] info"); $this->log4php->log('error',"error"); $this->log4php->log('warn',"warn");