This is documentation for Kohana v2.3.x.
Status | Draft |
---|---|
Todo | Proof read! |
Note:
This class is deprecated in version 2.2. Its methods are now in Kohana class.
Provides methods to work with logging.
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 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()
Kohana 2.2 makes a small change to the logging threshold order. levels 2 and 3 can be used without the overhead of debug. By default nothing is logged to level 2 or 3 by Kohana.
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