2012-04-04 28 views
0

私はkohana 3のサイトビルドで作業していますが、実際にはkohanaを使用し始めています。 私はエラーのための簡単なロギングを使用したいと思います。 私は、さまざまなものでアプリのパスからログディレクトリにエラーが発生し、私は自分自身の1つを追加しようとすると、エラーになる。これと間違っている何Kohanaログ - 書き込みエラー

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() 

:私は、このエラーに入る最後の行の後

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

私はこれが好きですか? ありがとう

答えて

4

メッセージタイプにログ定数を使用するだけです。

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

これらは、PHPでのエラーの種類を反映しているため。

P.S. Log :: write()を呼び出す必要はありません。シャットダウン時に自動的に行われます。