With the current Zend Framework Beta 0.9.2 release the Zend_Log component has been improved with a new fully object oriented design. There are lots of new features including Writers, Filters, Formatters and Events to discover and use in custom applications. The log Priorities have been doubled from 4 to 8 in the current release and it's now possible to add user defined log Priorities via the Zend_Log addPriority method. Due to the use of one of PHP magic functions it's even possible to send messages of the log Priority type simply by calling the 'priorityName()' method, i.e. $logger->audit('Auditional message'), of the Zend_Log object without further ado.
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.
Whilst touring the web I found an interesting project for turning Apache Web Server log files into RSS feeds. This approach can be adjusted to monitor the maintenance needs of a web application deployed on an assumed productive system. Therefor a XML capable Zend_Log instance will be set up and the resulting log file will be transformed into a RSS feed via a custom Action Helper wrapping a XSLT transformation.
As the current Zend_Log component doesn't provide very meaningful log content per default I wanted to extend the information logged and also the logfile layout. In the article of Stefan Koopmanschap this issue is solved by using the setMessagePrefix method of the Zend_Log class, which pushs the additional log information and layout unlovely to the Bootstrap file.
Another way to improve the content and layout being logged is writing a custom Zend_Log_Adapter by extending for instance Zend_Log_Adapter_File and overwriting its _parseLogLine metod and redefining its _options array.
In the new Zend_Log component of the Zend Framework Beta 0.9.2 release there are currently two log Filter available. The Zend_Log_Filter_Priority object can be used to filter out log Events having a log Priority greater than a specified log Priority value. The other Filter named Zend_Log_Filter_Message might be used to filter out specific log messages matching a Regular expression. The realization of a own Filter can be achieved quick and easy by implementing the Zend_Log_Filter_Interface interface.
There are different reasons for logging information, different strategies for what and how to log, and of course different ways of implementing it. This article will look at why you would want to log, what you want to log and how to do it.