Zend_Log
supports logging to multiple log adapters. It can either send a message to all
logs, or target a message to a specific log.
When creating multiple loggers, each log must be given a unique name. Loggers are registered with the
registerLogger()
method, with the log name supplied as the optional second argument.
In the example below, two loggers are created: one for the console, and one for a file. They will be
given the names Console
and File
, respectively.
require_once 'Zend/Log.php'; // Zend_Log base class require_once 'Zend/Log/Adapter/File.php'; // File log adapter require_once 'Zend/Log/Adapter/Console.php'; // Console log adapter Zend_Log::registerLogger(new Zend_Log_Adapter_File('/logs/framework.txt'), 'File'); Zend_Log::registerLogger(new Zend_Log_Adapter_Console(), 'Console');