^Status|Draft| ^Todo|Proof read!| ====== Log Class ====== **This class is deprecated in version 2.2. Its methods are now in Kohana class.** Provides methods to work with logging. ===== Configuration ===== 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 [[core:config|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: * 0 - Logging is disabled * 1 - Error messages including PHP errors * 2 - Debug messages * 3 - Informational messages 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 [[http://php.net/date|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. * 0 - Logging is disabled * 1 - Error messages including PHP errors * 2 - Application Alert messages (changed level) * 3 - Application Information messages (changed level) * 4 - Debug messages (new level) ===== Methods ===== ==== Adding entries to the log file==== ''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 ==== Writing the log entries to the file==== ''Log::write()'' is called by default on the shutdown event (event.shutdown). See for more information on events the [[[[core:event|Event]] page. There is typically no need to call it manually. Log::write(); // returns void