首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kohana日志-写入错误

Kohana日志-写入错误
EN

Stack Overflow用户
提问于 2012-04-04 22:19:57
回答 1查看 2.1K关注 0票数 0

我正在使用kohana 3上的一个网站,实际上我开始使用kohana了。我想使用一个简单的错误日志记录。我在不同应用程序路径的日志目录中得到错误,我尝试添加我自己的一个,然后进入错误。

我喜欢这样:

代码语言:javascript
复制
Kohana::$log->add('error', 'Could not locate user');
Kohana::$log->write();

在最后一行之后,我进入了这个错误:

代码语言:javascript
复制
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() 

这有什么问题呢?谢谢

EN

回答 1

Stack Overflow用户

发布于 2012-04-04 22:22:26

只需使用Log常量表示消息类型,例如

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

因为它们反映了PHP中的错误类型。

附注:不需要调用Log::write(),它在关机时自动完成。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10013051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档