A log system is an essential element for any application. It is a way to check the status and use of the application. For a basic implementation you can refer to the fig-stanrdars organization PSR-3 article, that describes th elogger interface.
Zend Framework 2 implement a Logger Component, the following is an example of how to use it with service manager.
LoggerAbstractServiceFactory is a Service Factory, as an example, into service Manager class Logger and will be used in the whole application. Log/App is the name of a single logger, and writer is an adapter that is used to choose the method of writing, in this case everything is written to file, but you can use a DB adapter and write your log into database.
With this configuration Log\App writes a string into data/app.log file, with INFO property. By default you can use an array of properties.
Usage of different keys is a good practice because it is very easy to write filter or log categories.
Another good practice, valid for all services in general, is to create your class extending single service.
This choice helps managing future customizations of services and is another important layer for managing unexpected updates.
Rali, thanks for your help with my robotic english! :P
did you enjoy the article? Buy me a coffe
or share the content