{
"require": {
"amberovsky/zf2-monolog": "~0"
}
}
- Add
Monolog
to yourconfig/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');
}
}