Chapter 11. Zend_Log

Table of Contents

11.1. Introduction
11.2. Logging to a Single Log
11.3. Log Levels
11.4. Advanced Logging: Multiple Loggers

11.1. Introduction

Zend_Log is a general purpose logging class. Zend_Log is a static class that can not be instantiated directly. It holds an array of instances of Zend_Log, one for each log used by the application. Each logger instance uses an adapter that implements Zend_Log_Adapter_Interface.

To use Zend_Log, include() the Zend_Log class and any adapter classes that will be used. For example, if an application will log to both the console (PHP's output buffer) and text files, the following files would be included:

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

Zend_Log can be used in a simplified way for a single log, can be configured for multiple logs, and can also be used to log internal operations of many Zend Framework classes.