8.2. Logging to a Single Log
Prev | Chapter 8. Zend_Log | Next

## 8.2. Logging to a Single Log

A Logger is created by calling the `Zend_Log::registerLogger()` method with a `Zend_Log_Adapter_Interface` instance as an argument.

    require_once 'Zend/Log.php';                // Zend_Log base class
    require_once 'Zend/Log/Adapter/File.php';   // File log adapter

    // Register the file logger
    Zend_Log::registerLogger(new Zend_Log_Adapter_File('/logs/simple.txt'));

Messages are then sent to the log with `Zend_Log::log()`.

    /**
     * Send a message to the log.  An optional second argument specifies the log
     * level.  If no level is supplied, LEVEL_DEBUG is assumed.
     */
    Zend_Log::log('First logging message.');

    /**
     * Log a severe message.
     */
    Zend_Log::log('A serious error has occurred.', Zend_Log::LEVEL_SEVERE);

Prev | Up | Next
Chapter 8. Zend_Log | Home | 8.3. Log Levels