coogle / logger
An Event-driven Logging module for Zend Framework 2
Installs: 81
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 3
Open Issues: 1
pkg:composer/coogle/logger
Requires
- zendframework/zendframework: >2.2.0
This package is not auto-updated.
Last update: 2025-10-25 19:55:38 UTC
README
Introduction
This is a relatively simple Logger Module for ZF2. It attaches to the 'log' event allowing it to capture logging events from any module that triggers that event.
Configuration
The logger class has the following configuration values available to it under the logger key as shown:
array(
'logger' => array(
'db_adapter' => null,
'logger_table' => 'application_log',
'priority_filter' => Logger::DEBUG,
'log_file' => '/tmp/application.log'
)
);
db_adapteris the database adapter to use (i.e.Zend\Db\Adapter\Adapteror such) if logging to a databaselogger_tableis the table we are writing log entries to (schema is in sql/create.sql)priority_filterthe priority to filter against when writing log entrieslog_filethe file on the local file system to log events to
Usage
To use the logger, you can trigger a 'log' event, for example as shown below from a class which implements the ServiceLocatorAwareInterface:
$eventManager = $this->getServiceLocator()->get('Application')->getEventManager();
$eventManager->trigger('log', $this, array('message' => "Testing Logging", 'priority' => Logger::ERR));
Alternatively, the Logger module comes with a Logger\LoggerTrait trait which can be used (provides a logEvent(<message>, <priority>) method which can be used in any class that provides the ServiceLocatorAwareInterface.