| 状态 | 草稿 |
|---|---|
| Todo | Proof read! |
| 官方最后更新时间 | 2008/08/11 15:59 |
The configuration file Log.php can be found in the application/config directory. If it's not there it can be copied from the system/config directory. See for more information on the 配置类(Config Class) page.
There are three settings for the Log class:
$config['threshold'] = 0; $config['directory'] = 'logs'; $config['format'] = 'Y-m-d H:i:s';
$config['threshold'] can be set at four levels:
When set to 3 it will also log 2 and 1. Same goes for 2.
Level 1 is recommended in production use as it will only log errors. Level 2 is useful while debugging, it will log all libraries loaded and any errors. Nothing is logged to level 3 by Kohana by default, but can be used for custom logging by applications.
Important setting the level to 2 or 3 can slow down your application significantly.
$config['directory'] log file directory, relative to application/, or absolute.
$config['format'] format for the timestamps according to date()
Log::add($type, $message) logs the message according to the type given (error,debug,info), the item will be preceded by a timestamp formatted according to $config['format'].
Log::add('error', 'Query went wrong'); // returns void Log::add('debug', 'Custom library X loaded'); // returns void
Log::write() is called by default on the shutdown event (event.shutdown). See for more information on events the 事件类(Event Class) page. There is typically no need to call it manually.
Log::write(); // returns void