aqilix / zf3-psr3-logger
PSR3 Logger for ZF3 and ZF2 Application
Installs: 46
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 0
pkg:composer/aqilix/zf3-psr3-logger
Requires
- php: ^5.6 || ^7.0
- container-interop/container-interop: ^1.1
- psr/log: ^1.0
- zendframework/zend-eventmanager: ^3.0
- zendframework/zend-log: ^2.9
- zendframework/zend-modulemanager: ^2.7.1
- zendframework/zend-servicemanager: ^3.0.3
- zendframework/zend-stdlib: ^3.0
Requires (Dev)
- phpunit/phpunit: ^5.5
- squizlabs/php_codesniffer: ^2.8
This package is not auto-updated.
Last update: 2025-10-20 21:18:27 UTC
README
This is a simple module for loading logger using PSR3 to your ZF3/ZF2 application. By default the logger will write to a file (data/log/system.log). But you can override the logger configuration by override logger in autoload/*.local.php.
By using this module you don't need to write delegators to modify the logger from Zend\Log.
Installation
Add zf3-psr3-logger to composer.json
composer require aqilix/zf3-psr3-logger
Add Aqilix\\ZF3PSR3Logger to config/modules.config.php
Usage
Inject psr3_logger service into class that wanna use logger. If using factories we can do it like this
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$example = new Example();
$example->setLogger($container->get("psr3_logger"));
return $example;
}
And here the Example class
class Example
{
use Psr\Log\LoggerAwareTrait;
public function test()
{
$this->logger->log(\Psr\Log\LogLevel::INFO, "{function} Testing logger", ["function" => __FUNCTION__]);
$this->logger->log(\Psr\Log\LogLevel::ERROR, "{function} Testing logger", ["function" => __FUNCTION__]);
}
}