Kohana Log - 写错误

时间:2012-04-04 14:19:57

标签: php kohana

我正在使用kohana 3上的网站构建,实际上我开始使用kohana。 我想使用简单的日志记录来查找错误。 我在应用程序路径中的日志目录中遇到错误,我尝试添加自己的一个错误。

我喜欢这个:

Kohana::$log->add('error', 'Could not locate user');
Kohana::$log->write();

在最后一行之后我遇到了这个错误:

ErrorException [ Notice ]: Undefined index: error

SYSPATH\classes\kohana\log\file.php [ 91 ]

86 
87      foreach ($messages as $message)
88      {
89          // Write each message into the log file
90          // Format: time --- level: body
91          file_put_contents($filename, PHP_EOL.$message['time'].' --- '.$this->_log_levels[$message['level']].': '.$message['body'], FILE_APPEND);
92      }
93  }
94 
95 } // End Kohana_Log_File
SYSPATH\classes\kohana\log\file.php [ 91 ] » Kohana_Core::error_handler(arguments)

SYSPATH\classes\kohana\log.php [ 184 ] » Kohana_Log_File->write(arguments)

APPPATH\classes\controller\main.php [ 23 ] » Kohana_Log->write()

{PHP internal call} » Controller_Main->action_index()

SYSPATH\classes\kohana\request\client\internal.php [ 118 ] » ReflectionMethod->invoke(arguments)

SYSPATH\classes\kohana\request\client.php [ 64 ] » Kohana_Request_Client_Internal->execute_request(arguments)

SYSPATH\classes\kohana\request.php [ 1138 ] » Kohana_Request_Client->execute(arguments)

DOCROOT\index.php [ 109 ] » Kohana_Request->execute() 

这有什么问题? 感谢

1 个答案:

答案 0 :(得分:4)

只需将日志常量用于消息类型,例如

Kohana::$log->add(Log::ERROR, 'Could not locate user');

因为这些反映了PHP中的错误类型。

P.S。没有必要调用Log :: write(),它在关机时自动完成。

相关问题