amberovsky/zf2-monolog

There is no license information available for the latest version (v0.0.4) of this package.

Monolog integration to Zend Framework 2

v0.0.4 2015-04-17 14:16 UTC

This package is not auto-updated.

Last update: 2020-01-10 15:31:00 UTC


README

Install

{
    "require": {
        "amberovsky/zf2-monolog": "~0"
    }
}

Usage

  • Add Monolog to your config/application.config.php.
  • Configure loggers (config/logs.php):
use Amberovsky\Monolog\Config;
use Monolog\Handler\StreamHandler;
use Formatter;

return [
	'monolog'	=> [
        'root'  => [
            Config::SECTION_HANDLERS    => [
                [
                    Config::HANDLER_CLASS   => StreamHandler::class,
                    Config::HANDLER_ARGS    => [
                        'path'  => '/var/log/root.log',
                    ],
                    
                    config::HANDLER_FORMATTER   => [
                        Config::FORMATTER_CLASS => Formatter::class,
                        Config::FORMATTER_ARGS  => [
                            
                        ]
                    ],
                ],
            ],
        ]
	]
];
  • Write to log:
use Amberovsky\Monolog\MonologFactoryTrait;

class Whatever {
    use MonologFactoryTrait;
    
    public function action() {
         $this->getMonologFactory()->getLogger('root')->debug('hello');
    }
}